Skip to main content
Home / Code Snippets / jQuery Code Snippets / Check if Event was Triggered or Native

Check if Event was Triggered or Native

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

$('button').trigger('click', true);
icon-link icon-logo-star icon-search icon-star