jQuery change() 方法
jQuery change() 方法 | 菜鸟教程 (runoob.com)
来源于菜鸟教程
定义和用法
当元素的值改变时发生 change 事件(仅适用于表单字段)。
change() 方法触发 change 事件,或规定当发生 change 事件时运行的函数。
注意:当用于 select 元素时,change 事件会在选择某个选项时发生。当用于 text field 或 text area 时,change 事件会在元素失去焦点时发生。
jQuery change() 方法 | 菜鸟教程 (runoob.com)
来源于菜鸟教程
当元素的值改变时发生 change 事件(仅适用于表单字段)。
change() 方法触发 change 事件,或规定当发生 change 事件时运行的函数。
注意:当用于 select 元素时,change 事件会在选择某个选项时发生。当用于 text field 或 text area 时,change 事件会在元素失去焦点时发生。
大家好我是山河,今天更新一个Jquery基础用法案例
上代码
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Jquery指哪打哪</title> <script src="https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js"></script> </head> <style> ul { list-style: none; } ul li { margin-top: 5px; } </style> <body> <ul class="one"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> </ul> <ul class="two"> <li>裤子</li> <li>鞋子</li> <li>袜子</li> <li>衬衫</li> </ul> <script> $(function() { $('.two li').eq(0).show().siblings().hide(); $('.one li').mouseover(function(){ var i = $(this).index() $('.two li').eq(i).show().siblings().hide(); }) }) </script> </body> </html>
好了,本文结束