- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 2416 Articles for HTML
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
385 Views
The HTML DOM Heading object is associated with the HTML heading elements ranging from to . Using the heading object we can create and access heading element with the createElement() and getElementById() method respectively.SyntaxFollowing is the syntax for −Creating a Heading object −var p = document.createElement("H1");ExampleLet us look at an example for the Heading object −Live Demo Heading object example Create a h1 element by clicking the below button CREATE function createH1() { var h = document.createElement("H1"); var txt = document.createTextNode("H1 element has been created"); h.appendChild(txt); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
The HTML DOM header object is associated with the HTML element that introduced in HTML 5. Using the header object we can create and access element using the createElement() and getElementById() method respectively.SyntaxFollowing is the syntax for −Creating a header object −var p = document.createElement("HEADER");ExampleLet us look at an example for the HTML DOM header object −Live Demo Header object example Create a header element by clicking the below button CREATE function headerCreate() { var h = document.createElement("HEADER"); document.body.appendChild(h); var h2 = document.createElement("H2"); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
182 Views
The HTML DOM head property is associated with the HTML element. It is used for returning the element. If there are multiple head elements then it will return the first head element. It is a read-only property.SyntaxFollowing is the syntax for the head property −document.headExampleLet us look at an example for the HTML DOM head property − My title head property example Get this document title by clicking on the below button Get Title function getTitle() { var x = document.head.firstElementChild.innerHTML; document.getElementById("Sample").innerHTML = "The title ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
95 Views
The HTML DOM HashChangeEvent is a type of interface used for representing those events that fire whenever the # part of the URL has been modified.PropertiesFollowing are the properties for the HashChangeEvent −PropertyDescriptionnewURLTo return the document URL after the hash has been modified.oldURLTo returns the document URL before the hash was changedSyntaxFollowing is the syntax for HashChangeEvent.event.eventPropertyHere, eventProperty is one of the above two properties.ExampleLet us look at an example for the HashChangeEvent.Live Demo HashChangeEvent example Change the hash by clicking the below button CHANGE function changeHash() { location.hash = "NEWHASH"; ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
93 Views
The HTML DOM hasFocus() method is used for knowing if the document or any element inside the document has focus. It does so by returning a boolean value in which true represents the document/element has focus and false represents otherwise.SyntaxFollowing is the syntax for hasFocus() method −document.hasFocus()ExampleLet us look at an example for the hasFocus() method −Live Demo hasFocus() method Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. CHECK ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
242 Views
The HTML DOM hasChildNodes() method is used for checking if an element contains child nodes or not. It returns true if the element does contain child nodes otherwise it returns false. It will consider any whitespace as child nodes as whitespace inside the node are basically considered as text nodes.SyntaxFollowing is the syntax for hasChildNodes() method −node.hasChildNodes()ExampleLet us look at an example for the hasChildNodes() method −Live Demo function checkChild() { var div = document.getElementById("DIV1").hasChildNodes(); document.getElementById("Sample").innerHTML = div; } hasChildNodes() method example This is ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
36 Views
The HTML DOM hasAttributes() method checks if an element has any attributes or not. It returns true if the element does contain any attribute and returns false if it doesn’t. If this method is called on any other node than the element node, the returned value will always be false.SyntaxFollowing is the syntax for hasAttribbutes() method −node.hasAttributes()ExampleLet us look at an example for the hasAttributes() method − hasAttributes() example This paragraph has no attributes CHECK The paragraph above hasAttribute value : function containsAttr() { var p = document.getElementsByTagName("P")[0]; document.getElementById("Sample").innerHTML+=p.hasAttributes(); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
131 Views
The HTML DOM getNamedItem() method is used for getting the attribute node with a given name as a NamedNodeMap object. To get that specific attribute node we have to call this method only upon the attributes property since the attribute property returns a list from which we can filter a specific attribute using getNamedItem() method.SyntaxFollowing is the syntax for the getNamedItem() method −namednodemap.getNamedItem(nodename)Here, nodename is a mandatory parameter value of type string indicating the name of the node present in the namedNodeMap.ExampleLet us look at an example for the getNamedItem() method −Live Demo getNamedItem() example USERNAME: ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
178 Views
The HTML DOM getElementsByTagName() method is used for getting the collection of all the elements in the document having a given tag name. It returns all the given elements as a NodeList object. You can access any element in the returned object using the index number.The HTMLcollection returned stays sync with the DOM tree without calling the getElementsByTagName() method again and again after removing or adding some elements.SyntaxFollowing is the syntax for the getElementsByTagName() method −element.getElementsByTagName(tagname)Here, tagname is a mandatory parameter value indicating the child elements tagname that we want to get.ExampleLet us look at an example for the getElementsByTagName() ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
262 Views
The HTML DOM getElementsByClassName() method is used for getting the collection of all the elements in the document having a given class name. It returns all the given elements as a NodeList object. You can access any element in the returned object using the index number. This method can be called on any individual element to have its descendant child elements having the given class name.SyntaxFollowing is the syntax for the getElementsByClassName() method −document.getElementsByClassName(classname)Here, the classname is of type string indicating the class name of element you want to access. Multiple class names can also be searched by separating them ... Read More