.bind() event using jQuery

-
.bind() event using jQuery
0 shares

To bind event to an element using jQuery is very easy task.
See the following examples,

$('#foo').bind('click', function() {
      // other stuff
});

You can also call external function like below,

function clickEvent()
{
    alert('Clicked');
}  

$('#foo').bind('click', clickEvent);

Another way to bind event,

$('#foo').click(clickEvent);

or you can write inline function like below,

$('#foo').click(function(){
    alert('Clicked');
});
0 shares

Leave a Reply

Your email address will not be published. Required fields are marked *