Here is the list of ways an HTML element can be accessed in a Javascript code:
getElementById(‘id_name’): // Fetches an element by its ID name getElementsByClass(‘class_name’): // Fetches all the elements that have the given classname. getElementsByTagName(‘tag_name’): // Fetches all the elements that have the given tag name. querySelector(): // This function takes css style selector and returns the first selected element.