Dan Dascalescu
Dan Dascalescu

Reputation: 151926

What DOM elements are not HTML elements?

The MDN documentation on addEventListener reads:

It works on any DOM element, not just HTML elements.

What DOM elements are not HTML elements? XML? Others?

Upvotes: 10

Views: 971

Answers (1)

Vincent Charette
Vincent Charette

Reputation: 136

You can add event listeners to any DOM object not only HTML elements. i.e the window object. Basically, all the statement is saying is that you are not confined to the HTML elements only.

The DOM is a W3C (World Wide Web Consortium) standard.

The DOM defines a standard for accessing documents:

"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."

The W3C DOM standard is separated into 3 different parts:

  • Core DOM - standard model for all document types

  • XML DOM - standard model for XML documents

  • HTML DOM - standard model for HTML documents

Here is a useful link which should give you more information about the HTML DOM http://www.w3schools.com/js/js_htmldom.asp.

You should also have a look at http://www.w3schools.com/js/js_htmldom_eventlistener.asp.

Here is the official W3C recommendation: http://www.w3.org/TR/DOM-Level-2-Core/introduction.html

Upvotes: 2

Related Questions