With JQuery, We can customize event functions, as shown in
[Javascript]
$ ("# Foo"). click (function (e ){
// Do work
});
We can also simulate the occurrence of click events, such
[Javascript]
$ ("# Foo"). click ()
Sometimes we need to distinguish this simulated event from the real user event.
Method 1:
We can determine whether a user clicks an event by passing the parameter e. If a user clicks an event, the object e will have attributes such as clientX, clientY, pageX, and pageY, all of which are numbers. You can also check the originalEvent attribute. The Code is as follows:
[Javascript]
$ ("# Foo"). click (function (e ){
If (e. hasOwnProperty ('ininalevent '))
// Probably a real click.
Else
// Probably a fake click.
});
Method 2:
You can also specify additional parameters when defining the event function. For details, see trigger api.
[Javascript]
$ ("# Foo"). click (function (e, from ){
If (from = null) from = 'user ';
// Rest of your code
});
$ ('# Foo'). trigger ('click', ['trigger']);