Click source in JavaScript and jQuery, human or automated?

后端 未结 4 2147
無奈伤痛
無奈伤痛 2020-12-11 18:40

We all know that you can simulate click or any other event on an element using one of these ways:

$(\'#targetElement\').trigger(\'eventName\');
$(\'#targetEl         


        
4条回答
  •  轮回少年
    2020-12-11 19:40

    Here's one way I have found (tested in Chrome)

    $('#foo').click(function(e) {
        if (e.originalEvent)
            alert('Has e (manual click)');
        else
            alert('No e (triggered)');
    });
    

    See here for testing: http://jsfiddle.net/ZPD8w/2/

提交回复
热议问题