2013-10-15 77 views
0

我创建了一个易趣上市,它在eBay上正常工作。jQuery和JavaScript onmouseover兼容性

但我有一个问题。该列表通过第三方软件列出,该软件拥有自己的JS用于更改图像。而且它不适用于我的脚本。我使用jQuery。

任何人都可以建议一个简单的方法来交换图像src点击事件?

例如:保持原样,但覆盖JS。现在它设置为侦听鼠标悬停。我可以写一个新的脚本,所以点击它将交换图像?

这里是链接到上市:Listing template here

回答

0

要改变图像的src属性:

$('#myImage').click(function(){ 
    $(this).attr('src', 'myNewImage.jpg'); 
}); 

要停止听鼠标悬停事件:

$('#myTargetWhichHasAnEventAttached').off('mouseover'); 

编辑答案评论:

$('.image_small_js').off('mouseover'); // supposed that the mouseover event is attached on .image_small_js 

$('.image_small_js').click(function(){ 
    $('#bigpicture').attr('src', $(this).attr('src')).hide().show(); // .hide().show() makes the change effect more smoothy... can be used with timers 
}); 
+0

我不知道它会为我工作吗? 我需要用'class =“image_small_js”'点击图片,然后将该图片的网址放入图片的src中,并用id =“bigpicture” –

+0

编辑好运 – Oliboy50

+0

yes,it works !谢谢。但我看到了另一个问题。 SRC不是我需要的。对不起!正如你可以看到缩略图的src是:[thumbnail](http://x.cloudsdata.net/9j/images/products/thumbnails/52318adcc396c_agua-de-loewe.jpg)和主图像是[大图]( http://x.cloudsdata.net/9j/images/products/large/52318adcc396c_agua-de-loewe.jpg),你可以看到文件夹从“缩略图”到“大”的变化是否可能影响到这一点? –