2013-10-15 76 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),你可以看到文件夾從「縮略圖」到「大」的變化是否可能影響到這一點? –