jQuery one() 方法
jQuery 教程
· 2019-03-26 20:42:45
实例
当点击 <p> 元素时,增加该元素的文本大小(每个 <p> 元素只能触发一次事件):
$("p").one("click",function(){
$(this).animate({fontSize:"+=6px"});
});
$(this).animate({fontSize:"+=6px"});
});
定义和用法
one() 方法为被选元素添加一个或多个事件处理程序,并规定当事件发生时运行的函数。
当使用 one() 方法时,每个元素只能运行一次事件处理程序函数。
语法
$(selector).one(event,data,function)
| 参数 | 描述 |
|---|---|
| event | 必需。规定添加到元素的一个或多个事件。 由空格分隔多个事件值。必须是有效的事件。 |
| data | 可选。规定传递到函数的额外数据。 |
| function | 必需。规定当事件发生时运行的函数。 |
点击查看所有 jQuery 教程 文章: https://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》 这本书的介绍吧!