2015-12-17 121 views
0

下面的HTML具有類service_img的簡單圖像標記。將jQuery鼠標懸停事件添加到元素

<img class="service_img" src="img/other/wedding.png" alt="wedding" /> 

這是JavaScript代碼,我寫道:

$('.service_img').mouseover(function(){ 
    $(this).addClass('animated jello'); 
}) 

如何添加一個jQuery鼠標懸停事件的img

+0

請試試這個http://stackoverflow.com/a/34331265/4763793 –

+0

一個簡單的谷歌搜索會給你這個鏈接。 https://api.jquery.com/mouseover/ –

回答

0
// Runs when the mouse enters the element 
$("img.service_img").on('mouseover',function(){ 
    $(this).addClass('animated jello'); 
}); 

// Runs when the mouse leaves the element 
$("img.service_img").on('mouseout',function(){ 
    $(this).removeClass('animated jello'); 
}); 
+0

不客氣。 – Jagadeesh

相關問題