开发者

After calling trigger on a browser event, how can I call a function when it has finished?

开发者 https://www.devze.com 2023-02-04 22:41 出处:网络
I\'m calling trigger on a checkbox to flip its state. Once this is done I need to call a function. Part of the function counts the number of boxes checked so this function can only be called after the

I'm calling trigger on a checkbox to flip its state. Once this is done I need to call a function. Part of the function counts the number of boxes checked so this function can only be called after the checkbox has flipped.

 $('input',this).trigger('click');

 // What do I do to call afterTrigger() when 'input' click event has fini开发者_开发百科shed.

 function afterTrigger(){
     // ... calculation
 }


You can call the function directly after the trigger event.

$('input',this).trigger('click'); 
afterTriger();


Calls to .trigger('foo') are synchronous, so you can just call your function.

$(this).find('input').trigger('click');
afterTrigger();
0

精彩评论

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