The querySelector() method returns the first child element that matches a specified CSS selector(s) of an element . Note: The querySelector() method only returns the first element that matches the specified selectors. To return all the matches, use the querySelectorAll() method instead.
Read moreWhat is getAttribute in JavaScript?
JavaScript getAttribute() method The getAttribute() method is used to get the value of an attribute of the particular element . If the attribute exists, it returns the string representing the value of the corresponding attribute. If the corresponding attribute does not exist, it will return an empty string or null.
Read more