GlobalEventHandlers.onchange

  • Revision slug: DOM/element.onchange
  • Revision title: element.onchange
  • Revision id: 29869
  • Created:
  • Creator: Mgjbot
  • Is current revision? No
  • Comment robot Adding: [[fr:DOM:element.onchange]] <<langbot>>

Revision Content

{{ DomRef() }}

Summary

The onchange property sets and returns the onChange event handler code for the current element.

Syntax

element.onchange = event handling code

Notes

The following pseudo code illustrates how the change handler is implemented in Mozilla:

  control.onfocus = focus;
  control.onblur = blur;
  function focus () {
      original_value = control.value;
  }

  function blur () {
      if (control.value != original_value)
        control.onchange();
  }

As a result, you might experience unexpected behavior from the change event if you alter the value of the control in your own focus or blur event handlers. Also, the change event is fired after the blur event. This behavior differs from IE.

Specification

DOM Level 0 (pre-dates specifications)

See Also

DOM Level 2: HTML event types

{{ languages( { "fr": "fr/DOM/element.onchange" } ) }}

Revision Source

<p>
{{ DomRef() }}
</p>
<h3 name="Summary">Summary</h3>
<p>The <code>onchange</code> property sets and returns the <code>onChange</code> event handler code for the current element.
</p>
<h3 name="Syntax">Syntax </h3>
<pre class="eval">element.onchange = event handling code
</pre>
<h3 name="Notes">Notes </h3>
<p>The following pseudo code illustrates how the change handler is implemented in Mozilla:
</p>
<pre>  control.onfocus = focus;
  control.onblur = blur;
  function focus () {
      original_value = control.value;
  }

  function blur () {
      if (control.value != original_value)
        control.onchange();
  }
</pre>
<p>As a result, you might experience unexpected behavior from the <code>change</code> event if you alter the value of the control in your own <code>focus</code> or <code>blur</code> event handlers. Also, the <code>change</code> event is fired after the <code>blur</code> event. This behavior differs from IE.
</p>
<h3 name="Specification">Specification</h3>
<p>DOM Level 0 (pre-dates specifications)
</p>
<h3 name="See_Also">See Also</h3>
<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-eventgroupings-htmlevents">DOM Level 2: HTML event types</a>
</p>
<div class="noinclude">
</div>
{{ languages( { "fr": "fr/DOM/element.onchange" } ) }}
Revert to this revision