Tuesday, August 18, 2009

Event Handler on jQuery

Just tried to implement event handler in jQuery. The first impression that I have is simple, easy and straight forward. Yeps, what do you need to do is just binding event name with certain function and then of course, you need to trigger the event.

Below is an example on how to bind the certain object in javascript using jQuery:

$(document).bind('kampred.facebox', function(){
alert("si kampred");

The above will bind event named kampred.facebox to object document. In order to call this event and let the handler execute the function. What you need to do is to trigger it. Below is the example on how to do it.


Calling the above line, will trigger the event kampred.facebox. Of course, it will prompt you an alert box. Its simple, isnt it.