0

I've got a Jquery function:

$('#element').click(function(){..........});

Is there a way to check in this function whether it was triggered by real mouse or just by script $('#element').click();?

Thanks for answers.

Joran Den Houting
  • 3,149
  • 3
  • 21
  • 51

1 Answers1

3

I think you can check e.originalEvent:

$('#element').click(function(e){
  if (e.originalEvent !== undefined)
  {
    alert ('Mouse clicked');
  }
  else 
  {
    alert( 'triggered programmatically' );   
  }
});
Nadeem_MK
  • 7,533
  • 7
  • 50
  • 61