title
This attribute represents textual information de scribing the ele ment it belon gs to, typ-
ically in the fo rm of a tooltip.
C.11 Event-Handler Attributes
One way that HTML elements c an get notified of events (e.g., mouse clicks or key
presses) is to specify an event handler using the corresponding HTML attribute on
an element that needs to respond to the event. Event-handler attribute names b egin
with on and are the same as the nam es of the event-handler properties defined by the
JavaScript Element object. You can find some of them in the table on page 402.
Using HTM L event-handler attributes to specify event handlers is not in line with go od
practice. Nam ely, it requires mixing structure (HTML) and behavior (JavaScript). A
much better approach is using the analogous properties of the Element JavaScript
object, or even the addEventListener() method of the EventTarget object. The
latter is not covered in this book , though.
Example
<!-- A click on the following <p> element will trigger the
JavaScript alert() method. -->
<p onclick="alert(’Don’t you ever listen?’)">Don’t click me!</p>
338 HTML Reference
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.130.232