Add jQuery function to specific elements

For jQuery 1.7 and later, use .on() and .trigger()

$('button').on('someFunction',function() {
    alert('go away!')
});


$('button').click(function(){
    $(this).trigger('someFunction');
});

Before jQuery 1.7 we used .bind() method for attaching event handlers (instead of .on()).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)