To get all the HTML tags present in a website using JavaScript, you can use the getElementsByTagName() method in the global document object and then pass the asterisk symbol * as an argument to it.
// Get all HTML tags
const allHTMLTags = document.getElementsByTagName("*");
- The method returns an array-like object called HTMLCollectionwhich you can also loop to get single tags.
See this example live in JSBin.
 
 
              
 
    
Top comments (0)