这个 悬停() 是jQuery中的一个内置方法,用于指定鼠标指针移动到选定元素上时要启动的两个函数。 语法:
null
$(selector).hover(Function_in, Function_out);
这里的选择器是选定的元素。 参数: 它接受下面指定的两个参数-
- 功能_在: 它指定鼠标输入事件发生时要运行的函数。
- 功能输出: 它是可选的,指定鼠标离开事件发生时要运行的函数。
返回值: 它返回选定元素的背景色效果。
< html > < head > < script src = </ script > < script > <!-- jQuery code to show the working of hover() method --> $(document).ready(function() { $("p").hover(function() { $(this).css("background-color", "green"); }, function() { $(this).css("background-color", "yellow"); }); }); </ script > < style > p { width: 55%; height: 80px; padding: 20px; margin: 10px; border: 2px solid green; font-size: 50px; } </ style > </ head > < body > <!--move the mouse in and out over this paragraph and background color will change--> < p >GeeksforGeeks !</ p > </ body > </ html > |
输出: 在将鼠标指针移到段落上之前- 将鼠标指针移到段落上方后-
鼠标指针从段落移出后-
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END