What does event binding mean?
Event binding refers to telling the browser that a particular function should be called whenever some 'event' occurs. Events mostly relate to user input, such as clicks.
An example of binding to an event in jQuery can be the following:
$("#elem").bind("click", function() {
alert("Clicked!");
});
This binds a function to click
event of DOM object with identifier elem
. When user clicks it, an alert (message box) will be shown. Binding is done by invoking the jQuery bind
function but there are other means to do that, (e.g. jQuery click
function in case of binding to click
event).
When you bind something to an event, it will be triggered when the event is fired. It's like gluing a fog horn to the brake pedal on your car.