jquery - Check if event is triggered by a human -



jquery - Check if event is triggered by a human -

i have handler attached event , execute if triggered human, , not trigger() method. how tell difference?

for example,

$('.checkbox').change(function(e){ if (e.ishuman()) { alert ('human'); } }); $('.checkbox').trigger('change'); //doesn't alert

you can check e.originalevent: if it's defined click human:

look @ fiddle http://jsfiddle.net/uf8wv/

$('.checkbox').change(function(e){ if (e.originalevent !== undefined) { alert ('human'); } });

my illustration in fiddle:

<input type='checkbox' id='try' >try <button id='click'>click</button> $("#try").click(function(event) { if (event.originalevent === undefined) { alert('not human') } else { alert(' human'); } }); $('#click').click(function(event) { $("#try").click(); });

jquery

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -