127.Python修炼之路【132-前端-JQuery主动触发与自定义事件】2018.08.02

主动触发与自定义事件

主动触发 
可使用jquery对象上的trigger方法来触发对象上绑定的事件。

自定义事件 
除了系统事件外,可以通过bind方法自定义事件,然后用tiggle方法触发这些事件。

//给element绑定hello事件
element.bind("hello",function(){
    alert("hello world!");
});

//触发hello事件
element.trigger("hello");

猜你喜欢

转载自blog.csdn.net/youyouwuxin1234/article/details/81356760