mouseleave()方法是jQuery中的一个内置方法,当鼠标指针离开所选元素时,它就会工作。
null
语法:
$(selector).mouseleave(function)
参数: 此方法接受单个参数 作用 这是可选的。它用于指定调用mouseleave事件时要运行的函数。
返回值: 此方法返回所选元素,其中包含mouseleave()方法所做的更改。
下面的示例演示了jQuery中的mouseleave()方法:
例子:
<!DOCTYPE html> < html > < head > < title >The mouseleave Method</ title > < script src = </ script > <!-- jQuery code to show the working of this method --> < script > $(document).ready(function() { $("p").mouseleave(function() { $("p").css("background-color", "lightgreen"); }); }); </ script > < style > body { width: 300px; padding: 40px; height: 30px; border: 2px solid green; font-weight: bold; font-size: 20px; } </ style > </ head > < body > <!-- move over this paragraph and see the change --> < p >Welcome to GeeksforGeeks!</ p > </ body > </ html > |
输出: 在将鼠标移到段落上之前: 将鼠标移到段落上后。
相关文章:
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END