jQuery change() 方法
jQuery 教程
· 2019-03-09 20:43:15
实例
当 <input> 字段改变时警报文本:
$("input").change(function(){
alert("文本已被修改");
});
alert("文本已被修改");
});
定义和用法
当元素的值改变时发生 change 事件(仅适用于表单字段)。
change() 方法触发 change 事件,或规定当发生 change 事件时运行的函数。
注意:当用于 select 元素时,change 事件会在选择某个选项时发生。当用于 text field 或 text area 时,change 事件会在元素失去焦点时发生。
语法
触发被选元素的 change 事件:
$(selector).change()
添加函数到 change 事件:
$(selector).change(function)
| 参数 | 描述 |
|---|---|
| function | 可选。规定针对被选元素当 change 事件发生时运行的函数。 |
点击查看所有 jQuery 教程 文章: https://www.codercto.com/courses/l/35.html
Head First Web Design
Ethan Watrall、Jeff Siarto / O’Reilly Media, Inc. / 2009-01-02 / USD 49.99
Want to know how to make your pages look beautiful, communicate your message effectively, guide visitors through your website with ease, and get everything approved by the accessibility and usability ......一起来看看 《Head First Web Design》 这本书的介绍吧!