Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 Jquery 函数:
$('#element').click(function(){..........});
有没有办法检查这个函数是由真正的鼠标触发还是由脚本触发的$('#element').click();?
$('#element').click();
感谢您的回答。
我认为您可以检查e.originalEvent:
$('#element').click(function(e){ if (e.originalEvent !== undefined) { alert ('Mouse clicked'); } else { alert( 'triggered programmatically' ); } });