DOM Event Handler - On Properties with Javascript (Interface Definition Language - IDL )

About

An IDL event handler is a way to define an event handler for one element via the on javascript properties known as the Interface Definition Language (IDL) (ie defined in the object interface, in the code)

An event handler can also be set via the on HTML attribute

Example

var btn = document.querySelector('button');
  • Javascript: setting of the handler via the onclick idl property
btn.onclick = function() {
   console.log('Ouch !');
}
  • The HTML button
<button class="btn btn-info">Poke me</button>
  • The result:

List


Powered by ComboStrap