December 2013
Intermediate to advanced
384 pages
9h 54m
English
function clickHandler(e){ $("div").html("clicked at X postion: " + e.screenX); } . . . <div onclick="clickHandler(event)">Click Here</div>
The most basic method of adding an event handler to a DOM element is directly in the HTML code. The advantage of this method is that it is simple and easy to see what event handler is assigned to a particular DOM object.
Event handlers are added to DOM objects in HTML by setting the value of the handler attribute in the tag statement. For each event that the element supports, there is an attribute that starts with on followed by the name of the event. For example, the click event attribute is onclick, and the load event attribute is onload ...
Read now
Unlock full access