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