$('button').click(function(event, wasTriggered) {
if (wasTriggered) {
alert('triggered in code');
} else {
alert('triggered by mouse');
}
});
$('button').trigger('click', true);
$('button').click(function(event, wasTriggered) {
if (wasTriggered) {
alert('triggered in code');
} else {
alert('triggered by mouse');
}
});
$('button').trigger('click', true);