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,141
  • 3
  • 20
  • 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,317
  • 7
  • 47
  • 59