Latest web development tutorials

jQuery one () method

jQuery Event Methods jQuery Event Methods

Examples

When you click <p> element, the element to increase the size of text (each <p> element can only trigger an event):

$("p").one("click",function(){
$(this).animate({fontSize:"+=6px"});
});

try it"

Definition and Usage

one () method is to add one or more elements selected from the event handler, and when a predetermined function to run when the event occurs.

When using one () method, each element can only run one event handler function.


grammar

$(selector).one(event,data,function)

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

由空格分隔多个事件值。必须是有效的事件。
data 可选。规定传递到函数的额外数据。
function 必需。规定当事件发生时运行的函数。


jQuery Event Methods jQuery Event Methods