jQuery event.target无法在firefox和IE中运行?

jQuery event.target无法在firefox和IE中运行?

问题描述:

我正在制作一个图像滑块,用于加载用户使用jQuery点击的图像。我在Chrome中工作得很好但是当我在firefox和IE中尝试它时根本没有加载图像。这是我的代码:

I'm working on making an image slider that loads the image the user clicks on using jQuery. I have it working great in Chrome but when I tried it in firefox and IE it's not loading the image at all. Here's my code:

    $("img.clickable").click( function() {
    $("#image_slider").animate({opacity:1.0,left:200},"slow");
    $("#image_container").attr("src",event.target.src);
    ihidden = false;
});

当我尝试在firefox或IE中运行它时,它根本不加载图像。有任何想法吗? :)

When I try running this in firefox or IE it just doesn't load the image at all. Any ideas? :)

您需要在参数中定义事件

You need to define the event in the arguments.

$("img.clickable").click( function(event) {
    $("#image_slider").animate({opacity:1.0,left:200},"slow");
    $("#image_container").attr("src",event.target.src);
    ihidden = false;
});

否则它将使用 window.event