jQuery: How do I use event.preventDefault() with custom events?

后端 未结 5 536
逝去的感伤
逝去的感伤 2021-02-01 02:48

How can I know in my triggering code that preventDefault has been called?

$(document).trigger(\'customEvent\', params);
if (/* ??? */)
    doDefault         


        
5条回答
  •  感情败类
    2021-02-01 03:29

    Custom events do not have some default actions that happens .. (they are custom).

    On the other hand, if you want to stop the bubbling effect of this event to others then have a look at triggerHandler which does not bubbles up to the hierarchy ..

提交回复
热议问题