JQuery FireFox点击事件

时间:2013-10-31 14:37:03

标签: jquery firefox click

我目前正在努力使用Firefox中的以下Jquery代码。 我的目标是在单击图像时重新加载img src路径。

HTML 5

<script src="//code.jquery.com/jquery-latest.min.js"></script>
<a href="#" id="image"><img src="image/image1.jpg" alt="ein smiley" /></a>

JQuery(最新版本)

$(document).ready(function() {     
    $('#image').click(function(event) {
       event.preventDefault();
       $('img', this).attr('src', 'image/image2.jpg');

    });
});

此代码在Internet Explorer 10和Google Chrome 30中运行良好。 但它在FireFox中不起作用。我已经读过FireFox将点击解释为表单提交。不幸的是,该线程中的解决方案非常有限,因为我不是真正的JQuery / Javascript专家,所以我无法使用该信息来解决问题。

您可以在此处查看原始网站:http://user.enterpriselab.ch/~tajoesle/ajax.php

你们其中一个人会这么好并帮助我吗?

非常感谢, 托马斯

1 个答案:

答案 0 :(得分:1)

在提供的演示网址中,可能是

的原因

http://user.enterpriselab.ch/~tajoesle/ajax.php

我发现以下js文件有404错误

    <script src="script\jquery.cookie.js\jquery.cookie.js"></script>
    <script src="script\style.switch\style.switch.js"></script>
    <script src="script\image.switch\image.switch.js"></script> 

但它应该是

    <script src="script/jquery.cookie.js/jquery.cookie.js"></script>
    <script src="script/style.switch/style.switch.js"></script>
    <script src="script/image.switch/image.switch.js"></script>