开发者

JQuery subglobal event

开发者 https://www.devze.com 2023-01-26 00:20 出处:网络
JQuery supports global events. These are used for things like \"ajaxComplete\" and similate. I\'ve also made my own globale events like that from time to time, and what it does \"behind the scenes\",

JQuery supports global events. These are used for things like "ajaxComplete" and similate. I've also made my own globale events like that from time to time, and what it does "behind the scenes", that JQuery don't show me (the developer), and that I really don't care about is that it calls that event on every item in the JQuery-cache. However, I came up with a project where subglobal events would really simplify my work. For instance, say that I want th开发者_开发问答e event to fire on all childelements (recursively, without having to manually write a recursive function-loop) of a given element. For instance, I want the event to fire on all inputs on the form #form1. How would I go about doing this?


To fire an event, you can use the .trigger() method:

$('#form1 :input').trigger('customevent');
0

精彩评论

暂无评论...
验证码 换一张
取 消