jQuery bind() 方法

jQuery 教程 · 2019-03-10 20:58:02

实例

向 <p> 元素添加一个单击事件:

$("p").bind("click",function(){
    alert("这个段落被点击了。");
});

定义和用法

bind() 方法向被选元素添加一个或多个事件处理程序,以及当事件发生时运行的函数。

自 jQuery 版本 1.7 起,on() 方法是向被选元素添加事件处理程序的首选方法。

语法


  
    $(selector).bind(event,data,function,map)
  

参数 描述
event 必需。规定添加到元素的一个或多个事件。

由空格分隔多个事件值。必须是有效的事件。
data 可选。规定传递到函数的额外数据。
function 必需。规定当事件发生时运行的函数。
map 规定事件映射 ({event:function, event:function, ...}),包含要添加到元素的一个或多个事件,以及当事件发生时运行的函数。

点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html

查看所有标签

Software Engineering for Internet Applications

Software Engineering for Internet Applications

Eve Andersson、Philip Greenspun、Andrew Grumet / The MIT Press / 2006-03-06 / USD 35.00

After completing this self-contained course on server-based Internet applications software, students who start with only the knowledge of how to write and debug a computer program will have learned ho......一起来看看 《Software Engineering for Internet Applications》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

URL 编码/解码
URL 编码/解码

URL 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具