Home  >  Article  >  Web Front-end  >  jQuery实现自定义事件的方法_jquery

jQuery实现自定义事件的方法_jquery

WBOY
WBOYOriginal
2016-05-16 16:03:181279browse

本文实例讲述了jQuery实现自定义事件的方法。分享给大家供大家参考。具体分析如下:

jQuery是一个非常强大的工具。jQuery非常有用的功能之一是可以实现事件绑定。你可以实现创建,绑定事件,可触发自己定义的jQuery事件。

自定义事件触发

下面的代码是它自定义事件触发。你可以绑定到这个自定义事件。

$event.trigger("myEventName");

自定义事件绑定

下面的代码创建了一个绑定到自定义事件和自定义事件触发时将被执行。

$(this).bind("myEventName",function(){
alert("myEventName triggered");
});

可见JQuery的自定义事件是非常有用的。

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

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