|
.on( "Event_Name", Listener_function ) - Attach an event
Events can be attached to elements ($.Objs) using ".on()" function
Parameters
Returns
Example 1
Attaching a "click" event to div elements with a listener which shows an alert box
JS
HTML
CSS
$.domLoaded(function() {
//Attach "click" event to div
$.get("div").on("click", function() {
alert("You Clicked on Div elements");
});
});
Result
Example 2
Attaching a "click" event to div elements with a listener using function reference
JS
HTML
CSS
$.domLoaded(function() {
var listen_to_click = function() {
alert("You Clicked on Div elements");
}
//Attach "click" event to div with function reference
$.get("div").on("click", listen_to_click);
});
Result
| ||||||||||||||||||||||
