jQuery hover() 方法
jQuery 教程
· 2019-03-09 22:27:20
实例
当鼠标指针悬停在上面时,改变 <p> 元素的背景颜色:
$("p").hover(function(){
$("p").css("background-color","yellow");
},function(){
$("p").css("background-color","pink");
});
定义和用法
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 );
| 参数 | 描述 |
|---|---|
| inFunction | 必需。规定 mouseover 事件发生时运行的函数。 |
| outFunction | 可选。规定 mouseout 事件发生时运行的函数。 |
点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html
数据结构算法与应用
塞尼 / 机械工业出版社 / 1999-3 / 49.00元
数据结构、算法与应用—C++语言描述(英文版),ISBN:9787111070177,作者:(美)塞尼 著一起来看看 《数据结构算法与应用》 这本书的介绍吧!