2013-12-09 91 views
0

我有一個jquery函數,它工作正常,直到我嘗試命名它。誰能告訴我我做錯了什麼?謝謝!jquery命名功能不起作用

http://jsfiddle.net/Alga/UaZ65/4/

function thumbHover() { 
    $('.thumb').hover(function() { 
     $('.info-top p').text('Hover Text'); 
    }, 
    function() { 
     if (!$('.info-top p').hasClass('active')) { 
      $('.info-top p').text(''); 
     } 
    }); 
} 

回答

0

試試這個

$(function(){ 
    $('.thumb').hover(function() { 
    $('.info-top p').text('Hover Text'); 
    }, 
    function() { 
    if (!$('.info-top p').hasClass('active')) { 
     $('.info-top p').text(''); 
    } 
    }); 
}); 

Demo

1

thumbHover()功能不被調用。只需刪除您的功能或正確調用它即可使您的代碼正常工作。

更新Fiddle