December 2013
Intermediate to advanced
384 pages
9h 54m
English
$("p").on("click", function (e){ $(this).html("You clicked here."); }); $("span").on("dblclick", function (e){ $(this).html("You double-clicked here."); });
To register a click handler in jQuery, you should use the .on("click") or .on("dblclick") method. Inside the handler function, you can perform whatever event functionality your application requires. It is easy to apply the click handler to multiple objects using jQuery selectors. For example, the following applies a click handler to all <div> elements:
$("div").on("click", function (e){ $(this).html("You clicked here."); });
Read now
Unlock full access