jQuery event.target无法在firefox和IE中运行? [英] jQuery event.target not working in firefox and IE?

查看:85
本文介绍了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

这篇关于jQuery event.target无法在firefox和IE中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆