Quick Reference
This is a quick reference list of JavaScript DOM Documents methods and properties with examples of how they are used.
- JavaScript – DOM document.activeElement PropertyThe document.activeElement property returns the HTML element that has focus.
- JavaScript – DOM document.addEventListener() MethodThe document.addEventListener() method attaches an event handler to a document.
- JavaScript – DOM document.adoptNode() MethodThe document.adoptNode() method adopts a node from another document.
- JavaScript – DOM document.baseURI PropertyThe document.baseURI property returns the base URI of the document.
- JavaScript – DOM document.body PropertyThe document.body property returns the document’s <body> element.
- JavaScript – DOM document.characterSet PropertyThe document.characterSet property returns the character encoding for the document.
- JavaScript – DOM document.close() MethodThe document.close() method closes a document previously opened with the open() method.
- JavaScript – DOM document.cookie PropertyThe document.cookie property returns a semicolon-separated list of key=value pairs (document cookies).
- JavaScript – DOM document.createAttribute() MethodThe document.createAttribute() method creates an attribute and returns the attribute as an Attr object.
- JavaScript – DOM document.createComment() MethodThe document.createComment() method creates a comment and returns the comment node.
- JavaScript – DOM document.createDocumentFragment() MethodThe document.createDocumentFragment() method creates a new document fragment that can be inserted into any document.
- JavaScript – DOM document.createElement() MethodThe document.createElement() method creates an element node.
- JavaScript – DOM document.createEvent() MethodThe document.createEvent() method creates an event object.
- JavaScript – DOM document.createTextNode() MethodThe document.createTextNode() method creates a text node.
- JavaScript – DOM document.defaultView PropertyThe document.defaultView property returns the document’s window object.
- JavaScript – DOM document.designMode PropertyThe document.designMode property sets or returns if the document is editable.
- JavaScript – DOM document.doctype PropertyThe document.doctype property returns a document’s doctype object. And doctype.name returns the name of the doctype.
- JavaScript – DOM document.documentElement PropertyThe document.documentElement property returns a document’s element object.
- JavaScript – DOM document.documentURI PropertyThe document.documentURI property sets or returns a document’s location.
- JavaScript – DOM document.domain PropertyThe document.domain property returns the domain name of the server the document was loaded from.
- JavaScript – DOM document.embeds PropertyThe document.embeds property returns a collection of all <embed> elements in the document.
- JavaScript – DOM document.forms PropertyThe document.forms property returns a collection of all <form> elements in a document.
- JavaScript – DOM document.hasFocus() MethodThe document.hasFocus() method returns “true” if the document, or any element in the document, has focus. Otherwise it returns “false”.
- JavaScript – DOM document.head PropertyThe document.head property returns the <head> element of the document.
- JavaScript – DOM document.images PropertyThe document.images property returns a collection of all <img> elements in a document.
- JavaScript – DOM document.importNode() MethodThe document.importNode() method imports a node from another document, and with the second parameter set to true, will also import child nodes.
- JavaScript – DOM document.lastModified PropertyThe document.lastModified property returns the date and time the document was last modified.
- JavaScript – DOM document.links PropertyThe document.links property returns a collection of all links (<a> and <area> elements) in the document.
- JavaScript – DOM document.normalize() MethodThe document.normalize() method removes empty text nodes, and joins adjacent text nodes.
- JavaScript – DOM document.open() MethodThe document.open() method opens a document for writing.
- JavaScript – DOM document.readyState PropertyThe document.readyState property returns the loading status of the current document.
- JavaScript – DOM document.referrer PropertyThe document.referrer property returns the URL of the document that loaded the current document.
- JavaScript – DOM document.removeEventListener() MethodThe document.removeEventListener() method removes an event handler from a document.
- JavaScript – DOM document.scripts PropertyThe document.scripts property returns a collection of all <script> elements in the document.
- JavaScript – DOM document.title PropertyThe document.title property sets or returns the title of the document.
- JavaScript – DOM document.URL PropertyThe document.URL property returns the full URL of the document.
- JavaScript – DOM document.write() MethodThe document.write() method writes directly to an open HTML document.
- JavaScript – DOM document.writeln() MethodThe document.writeln() method writes directly to an open HTML document, with the addition of writing a newline character after each statement.
JavaScript Notes:
- When using JavaScript, single or double quotation marks are acceptable and work identically to one another; choose whichever you prefer, and stay consistent
- JavaScript is a case-sensitive language; firstName is NOT the same as firstname
- Arrays count starting from zero NOT one; so item 1 is position [0], item 2 is position [1], and item 3 is position [2] … and so on
- JavaScript variables must begin with a letter, $, or _
- JavaScript variables are case sensitive (x is not the same as X)
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.