jQuery hover() 方法


1 $("p").hover(function(){
2     $("p").css("background-color","yellow");
3 },function(){
4     $("p").css("background-color","pink");
5 });

定義和用法

hover() 方法規定當鼠標指針懸停在被選元素上時要運行的兩個函數。

方法觸發 mouseenter 和 mouseleave 事件。

注意: 如果只指定一個函數,則 mouseenter 和 mouseleave 都執行它。


語法

$( selector).hover( inFunction,outFunction)

調用:

$( selector ).hover( handlerIn, handlerOut )

等同以下方式:

$( selector ).mouseover( handlerIn ).mouseout( handlerOut );

注意:如果只規定了一個函數,則它將會在 mouseover 和 mouseout 事件上運行。

調用:

$(selector).hover(handlerInOut)

等同於:

$( selector ).on( "mouseover mouseout", handlerInOut );

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM