- JavaScript Basics
- JS Home
- JS Syntax
- JS Placements
- JS Output
- JS Statements
- JS Keywords
- JS Comments
- JS Variables
- JS var
- JS let
- JS const
- JS var Vs let Vs const
- JS Operators
- JS Arithmetic Operators
- JS Assignment Operators
- JS Comparison Operators
- JS Logical Operators
- JS Bitwise Operators
- JS Ternary Operator
- JS Operator Precedence
- JS Data Types
- JS typeof
- JS Conditional Statements
- JS Conditional Statement
- JS if Statement
- JS if...else Statement
- JS switch Statement
- JS Loops
- JS for Loop
- JS while Loop
- JS do...while Loop
- JS break Statement
- JS continue Statement
- JS break Vs. continue
- JavaScript Popup Boxes
- JS Dialog Box
- JS alert Box
- JS confirm Box
- JS prompt Box
- JavaScript Functions
- JS Functions
- JS setTimeout() Method
- JS setInterval() Method
- JavaScript Events
- JS Events
- JS onclick Event
- JS onload Event
- JS Mouse Events
- JS onreset Event
- JS onsubmit Event
- JavaScript Arrays
- JS Array
- JS Find Length of Array
- JS Add Elements at Beginning
- JS Add Element at End
- JS Remove First Element
- JS Remove Last Element
- JS Get First Index
- JS Get Last Index
- JS Reverse an Array
- JS Sort an Array
- JS Concatenate Arrays
- JS join()
- JS toString()
- JS from()
- JS Check if Value Exists
- JS Check if Array
- JS Slice an Array
- JS splice()
- JS find()
- JS findIndex()
- JS entries()
- JS every()
- JS fill()
- JS filter()
- JS forEach()
- JS map()
- JavaScript Strings
- JS String
- JS Length of String
- JS Convert to Lowercase
- JS Convert to Uppercase
- JS String Concatenation
- JS search()
- JS indexOf()
- JS search() Vs. indexOf()
- JS match()
- JS match() Vs. search()
- JS replace()
- JS toString()
- JS String()
- JS includes()
- JS substr()
- JS Slice String
- JS charAt()
- JS repeat()
- JS split()
- JS charCodeAt()
- JS fromCharCode()
- JS startsWith()
- JS endsWith()
- JS trim()
- JS lastIndexOf()
- JavaScript Objects
- JS Objects
- JS Boolean Object
- JavaScript Math/Number
- JS Math Object
- JS Math.abs()
- JS Math.max()
- JS Math.min()
- JS Math.pow()
- JS Math.sqrt()
- JS Math.cbrt()
- JS Math.round()
- JS Math.ceil()
- JS Math.floor()
- JS Math.trunc
- JS toFixed()
- JS toPrecision()
- JS Math.random()
- JS Math.sign()
- JS Number.isInteger()
- JS NaN
- JS Number()
- JS parseInt()
- JS parseFloat()
- JavaScript Date and Time
- JS Date and Time
- JS Date()
- JS getFullYear()
- JS getMonth()
- JS getDate()
- JS getDay()
- JS getHours()
- JS getMinutes()
- JS getSeconds()
- JS getMilliseconds()
- JS getTime()
- JS getUTCFullYear()
- JS getUTCMonth()
- JS getUTCDate()
- JS getUTCDay()
- JS getUTCHours()
- JS getUTCMinutes()
- JS getUTCSeconds()
- JS getUTCMilliseconds()
- JS toDateString()
- JS toLocaleDateString()
- JS toLocaleTimeString()
- JS toLocaleString()
- JS toUTCString()
- JS getTimezoneOffset()
- JS toISOString()
- JavaScript Browser Objects
- JS Browser Objects
- JS Window Object
- JS Navigator Object
- JS History Object
- JS Screen Object
- JS Location Object
- JavaScript Document Object
- JS Document Object Collection
- JS Document Object Properties
- JS Document Object Methods
- JS Document Object with Forms
- JavaScript DOM
- JS DOM
- JS DOM Nodes
- JS DOM Levels
- JS DOM Interfaces
- JavaScript Cookies
- JS Cookies
- JS Create/Delete Cookies
- JavaScript Regular Expression
- JS Regular Expression
- JS RegEx .
- JS RegEx \w and \W
- JS RegEx \d and \D
- JS RegEx \s and \S
- JS RegEx \b and \B
- JS RegEx \0
- JS RegEx \n
- JS RegEx \xxx
- JS RegEx \xdd
- JS RegEx Quantifiers
- JS RegEx test()
- JS RegEx lastIndex
- JS RegEx source
- JavaScript Advance
- JS Page Redirection
- JS Form Validation
- JS Validations
- JS Error Handling
- JS Exception Handling
- JS try-catch throw finally
- JS onerror Event
- JS Multimedia
- JS Animation
- JS Image Map
- JS Debugging
- JS Browser Detection
- JS Security
- JavaScript Misc
- JS innerHTML
- JS getElementById()
- JS getElementsByClassName()
- JS getElementsByName()
- JS getElementsByTagName()
- JS querySelector()
- JS querySelectorAll()
- JS document.write()
- JS console.log()
- JS instanceof
- JavaScript Programs
- JavaScript Programs
JavaScript DOM Interfaces
The DOM API provides interfaces to implement DOM. Each interface is associated with a particular type of node that is defined in the inheritance hierarchy, which are described in the following table:
Interface | Description |
---|---|
The DOMException Interface | This interface represents some exceptions and errors that occur due to an invalid DOM or when a non-existing node is passed as an argument of a method |
The DOMImplementation Interface | This interface provides some methods that help in performing certain operations that are not dependent on any document or instance of DOM |
The DocumentFragment Interface | This interface is used for temporarily storing the structure of DOM |
The Document Interface | This interface is the root node in the DOM tree. It defines the documentElement property of the document, which returns the root node by looping through all the child nodes of the Document nodes to test whether or not they are Element nodes |
The Node Interface | This interface is the base interface in the DOM tree. It means that all the other interfaces are derived from the Node interface |
The NodeList Interface | This interface provides an ordered collection of nodes without defining the method for implementing these nodes in DOM |
The NamedNodeMap Interface | The interface represents an unordered collection of nodes that can be accessed by their name |
The CharacterData Interface | This interface allows you to extend the node by providing a set of properties and methods, which you can use to access the character data in the DOM |
The Attr Interface | This interface represents an attribute of an element. It inherits the Node interface |
The Element Interface | This interface represents an element in an HTML document. |
The Text Interface | This interface inherits from the CharacterData interface and is used to represent the textual content of an Element or Attr node |
The Comment Interface | This interface is inherited from the CharacterData interface and is used to represent the comments of the XML or XHTML documents |
JavaScript DOMException Interface Exception Code
Here is the table lists exception code of DOMException interface in JavaScript.
Code | Exception |
---|---|
1 | INDEX_SIZE_ERR exception |
2 | DOMSTRING_SIZE_ERR exception |
3 | HIERARCHY_REQUEST_ERR exception |
4 | WRONG_DOCUMENT_ERR exception |
5 | INVALID_CHARACTER_ERR exception |
6 | NO_DATA_ALLOWED_ERR exception |
7 | NO_MODIFICATION_ALLOWED_ERR exception |
8 | NOT_FOUND_ERR exception |
9 | NOT_SUPPORTED_ERR exception |
10 | INUSE_ATTRIBUTE_ERR exception |
11 | INVALID_STATE_ERR exception |
12 | SYNTAX_ERR exception |
13 | INVALID_MODIFICATION_ERR exception |
14 | NAMESPACE_ERR exception |
15 | INVALID_ACCESS_ERR exception |
JavaScript Node Interface Properties and Methods
The table given below describes properties of Node interface in JavaScript.
Property | Description |
---|---|
nodeType | returns an integer value that represents the node type |
nodeName | returns the name of the node |
nodeValue | returns the value of the node |
attributes | returns an array of Attr objects that represents the attributes of the current node |
parentNode | returns the parent node of the current node if it exists, otherwise it returns a null value |
childNodes | returns an array of Node objects that represents the child nodes of the current node |
firstChild | returns a Node object that represents the first child of the current node, otherwise it returns a null value |
lastChild | returns a Node object that represents the last child of the current node, otherwise it returns a null value |
localName | returns a qualified name of the current node |
namespaceURI | returns the namespace URI of the current node |
nextSibling | returns the node that immediately follows the current node |
ownerDocument | returns a Document object associated with the current node |
prefix | returns the namespace prefix of the current node |
previousSibling | returns the node immediately preceding the current node |
The following table lists the methods of the Node interface in JavaScript.
Method | Description |
---|---|
appendChild | adds a new child node at the end of the list of the child nodes |
cloneNode | creates a duplicate node of the current node |
hasAttributes | returns true if the node has an attribute |
hasChildNodes | returns true if the node has child nodes |
insetBefore | inserts a new child node before the current child node |
inSupported | checks whether a specified feature is implemented by the DOM implementation and is supported by the current node |
normalize | places the sub-tree of the current node in state where the structural nodes separated by the text nodes |
removeChild | removes an existing child node from the list of child nodes |
replaceChild | replaces an existing child node with the new node |
JavaScript NamedNodeMap Interface Methods
Here is the table describes the methods of the NamedNodeMap interface in JavaScript.
Method | Description |
---|---|
getNamedItem | retrieves a node from the collection on the basis of its name |
getNamedItemNS | retrieves a node from the collection on the basis of its local name and namespace URI |
item | returns an item from the collection on the basis of its index number |
removeNamedItem | removes a node from the collection on the basis of its name |
removeNamedItemNS | removes a node from the collection on the basis of its local name and namespace URI |
setNamedItem | adds a node in the collection by using its nodeName attribute |
setNamedItemNS | adds a node in the collection by using the namespaceURI and localName of the new node |
JavaScript CharacterData Interface Methods
The table given below describes methods of the CharacterData interface in JavaScript.
Method | Description |
---|---|
appendData | appends string at the end of the character data of the current node |
deleteData | removes a range of 16-bit units from the current node |
insertData | inserts a string at the specified 16-bit unit offset |
replaceData | replaces the characters starting at the specified 16-bit unit offset with the specified string |
substringData | extracts a range of data from the node |
JavaScript Document Interface Methods
The following table describes methods of Document interface in JavaScript.
Method | Description |
---|---|
getElementByTagName | returns an array of element objects that have a tag name similar to the specified name |
getElementByTagNameNS | returns an array of an element object whose name attribute's value matches the value of the argument of this method |
getElementById | returns the element object that has the same id, as specified in the argument |
JavaScript Element Interface Methods
Here is the table describes methods of the Element interface in JavaScript.
Method | Description |
---|---|
hasAttribute() | returns true if the specified element has an attribute |
getAttribute() | returns the value of the attribute of the specified element |
setAttribute() | assigns the specified value to the specified attribute |
removeAttribute() | removes the specified attribute |
getElementByTagName() | returns an array of element objects whose name matches with that provided in the tagName attribute |
JavaScript Attr Interface Properties
The following table describes properties of the Attr interface in JavaScript.
Property | Description |
---|---|
name | specifies the name of the attribute |
value | specifies the value of the attribute |
ownerElement | returns the element node of the Attr object |
specified | returns true if the attribute is set by the user or returns false if the attribute is set by the default value |
« Previous Tutorial Next Tutorial »