Home >Web Front-end >JS Tutorial >Usage examples of bind() method in jQuery_jquery

Usage examples of bind() method in jQuery_jquery

WBOY
WBOYOriginal
2016-05-16 16:19:191109browse

The example in this article describes the usage of bind() method in jQuery. Share it with everyone for your reference. The specific analysis is as follows:

This method binds an event handler to a specific event of the matching element.
The bind() method is syntactically the same as the one() method. The difference lies in the number of executions of the bound processing method.

Grammar structure 1:

Copy code The code is as follows:
$(selector).bind(type,data,function)

Parameter list:
参数 描述
type 定义绑定到匹配元素中的事件类型。
如果有多个事件使用空格分隔。
data 可选。传递给事件对象的额外数据对象。
function 定义当事件发生时运行的方法。

Example code:

Copy code The code is as follows:






bind() function-Script Home





Script House welcomes you



Grammar structure 2:

Copy code The code is as follows:
$(selector).bind({type:function, type:function , ...})

Parameter list:

参数 描述
{type:function, type:function, ...}         定义绑定到匹配元素的事件和事件处理方法。
type与function参数描述如上表。

实例代码:

复制代码 代码如下:






bind()函数-脚本之家





 
脚本之家欢迎您



希望本文所述对大家的jQuery程序设计有所帮助。

本文转自:蚂蚁部落http://www.softwhy.com/

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn