What are the methods supported by W3C DOM?


The following are the method supported by W3C DOM −

Sr.No
Property & Description
1
createAttribute( name)
Returns a newly-created Attr node with the specified name.
Ex − document.createAttribute( name)
2
createComment( text)
Creates and returns a new Comment node containing the specified text.
Ex − document.createComment( text)
3
createDocumentFragment( )
Creates and returns an empty DocumentFragment node.
Ex − document.createDocumentFragment( )
4
createElement( tagName)
Creates and returns a new Element node with the specified tag name.
Ex − document.createElement( tagName)
5
createTextNode( text)
Creates and returns a new Text node that contains the specified text.
Ex − document.createTextNode( text)
6
getElementById( id)
Returns the Element of this document that has the specified value for its id attribute, or null if no such Element exists in the document.
Ex − document.getElementById( id)
7
getElementsByName( name)
Returns an array of nodes of all elements in the document that have a specified value for their name attribute. If no such elements are found, returns a zero-length array.
Ex − document.getElementsByName( name)
8
getElementsByTagName( tagname)
Returns an array of all Element nodes in this document that have the specified tag name. The Element nodes appear in the returned array in the same order they appear in the document source.
Ex − document.getElementsByTagName( tagname)


Updated on: 23-Jun-2020

53 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements