本教程操作环境:windows10系统、jquery3.2.1版本、dell g3电脑。
hover是jquery事件吗hover是jquery中的一个鼠标事件
页面对不同访问者的响应叫做事件。
事件处理程序指的是当 html 中发生某些事件时所调用的方法。
hover() 方法规定当鼠标指针悬停在被选元素上时要运行的两个函数。
方法触发 mouseenter 和 mouseleave 事件。
当鼠标指针离开被选元素时,会发生 mouseleave 事件。
当鼠标指针穿过(进入)被选元素时,会发生 mouseenter 事件。
语法为:
$(selector).hover(infunction,outfunction)
infunction 必需。规定 mouseenter 事件发生时运行的函数。
outfunction 可选。规定 mouseleave 事件发生时运行的函数。
示例如下:
<!doctype html><html><head><meta charset="utf-8"><title>123</title><script src="js/jquery.min.js"></script><script>$(document).ready(function(){ $("p").hover(function(){ $("p").css("background-color","yellow"); },function(){ $("p").css("background-color","pink"); });});</script></head><body><p>鼠标移动到该段落。</p></body></html>
输出结果:
相关视频教程推荐:jquery视频教程
以上就是hover是jquery事件吗的详细内容。
