jquery中mouseenter事件有什么用处

2024-10-14 03:36:06

1、新建一个html文件,命名为test.html,用于讲解jquery中mouseenter事件有什么用处。

jquery中mouseenter事件有什么用处

2、在test.html文件内,使用p标签创建一行文字。

jquery中mouseenter事件有什么用处

3、在test.html文件中,给p标签添加一个id属性,设置为mytest。

jquery中mouseenter事件有什么用处

4、在js标签内,通过id获得p元素对象,给它绑定mouseenter事件,当鼠标指针穿过元素时,执行function方法。

jquery中mouseenter事件有什么用处

5、在function方法内,使用this获得当前对象,再通过css()方法设置p标签的背景颜色为黄色。

jquery中mouseenter事件有什么用处

6、在浏览器打开test.html文件,当鼠标指针穿过p元素时,查看实现的效果。

jquery中mouseenter事件有什么用处
猜你喜欢