开发者

how do I tell if an event is fired by .click() or by the user?

开发者 https://www.devze.com 2023-02-28 02:20 出处:网络
I want to differentiate actual mouse clicks fro开发者_开发百科m script generated clicks.How can i do it with jquery?You could check for something that isn\'t included in a triggered event object.

I want to differentiate actual mouse clicks fro开发者_开发百科m script generated clicks.How can i do it with jquery?


You could check for something that isn't included in a triggered event object.

$('div').click(function(e) {
    if ( e.originalEvent ) {
        console.log('actual mouseclick');
    }
}).trigger('click');
0

精彩评论

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