10

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?

5
  • 4
    DOM is not HTML. DOM is an API for JavaScript, HTML is a markup language. The above posted statement means that it works both on DOM and HTML elements. There is nothing implied that they could by any means be the same thing. Commented Jul 1, 2015 at 6:30
  • text nodes, comment, etc? Commented Jul 1, 2015 at 6:30
  • A little correction to my above comment: DOM is an API specification and it is not specifically only for JavaScipt, though it is mostly used this way. Commented Jul 3, 2015 at 9:00
  • 1
    The HTML spec describes HTML in terms of a text document with a specific syntax. The DOM on the other hand describes the object-model that the browser generates, when it parses the HTML document. See at here you will get clarity Commented Jul 4, 2015 at 17:57
  • Text nodes, SVG elements Commented Jun 21, 2022 at 9:14

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.