mozilla

Compare Revisions

element.addEventListener

Change Revisions

Revision 232713:

Revision 232713 by michelesalvador on

Revision 232714:

Revision 232714 by michelesalvador on

Title:
element.addEventListener
element.addEventListener
Slug:
Talk:DOM/element.addEventListener
Talk:DOM/element.addEventListener
Tags:
NeedsHelp, needsattention, "MDC Project"
NeedsHelp, needsattention, "MDC Project"
Content:

Revision 232713
Revision 232714
n98        <a class=" external" href="http://jsfiddle.net/xfFMk/" tin98        <a class="external" href="http://jsfiddle.net/xfFMk/" tit
>tle="addEventListener basic example">jsfiddle.net/xfFMk</a>>le="addEventListener basic example">jsfiddle.net/xfFMk</a>
n101        The argument of a listener function is an instance of then101        The argument of a listener function is an instance of the
> Event itself (in this case a "Mouse Event"), that contains usefu> Event itself (in this case a "Mouse Event"), that contains usefu
>l information like <code>event.target</code> (the 'ear').>l information like foexample
nn103      <ul>
104        <li>
105          <code>event.type</code> : <em>click</em>, <em>onmouseov
 >er</em> etc.
106        </li>
107        <li style="list-style: none">
108          <dl>
109            <dt>
110              event.clientX
111            </dt>
112            <dd>
113              the horizontal coordinate of click in browser windo
 >w
114            </dd>
115            <dt>
116              event.target
117            </dt>
118            <dd>
119              the element to wich the listener is assigned, in th
 >is example the&nbsp;<code>&lt;div&gt;</code>&nbsp;<em>ear</em>
120            </dd>
121          </dl>
122        </li>
123      </ul>
n110    var text = <strong>event.target.firstChild.nodeValue</strong>n
>; 
111    document.getElementById('display').innerHTML = text;  // disp131    document.getElementById('display').innerHTML = <strong>event.
>lays "Click me">type</strong>;  // displays "click"
t134      -- <a href="/User:michelesalvador">Michele</a>, 6 Jun 2012t154      -- <a href="/User:michelesalvador" title="User:michelesalva
 >dor">Michele</a>, 6 Jun 2012

Back to History