Select an element or elements by given ID, class name, tag name, or CSS selector.
Select an element by given ID
<div id="hello" />
document.getElementById('hello');
Select elements by class name
Returns the list of elements that have hello
class within a given element:
ele.getElementsByClassName('hello');
Select elements by tag name
Returns the list of span
inside a given element:
ele.getElementsByTagName('span');
Select elements by CSS selector
Returns the list of elements that match a given selector:
ele.querySelectorAll('div.hello');
Returns the first element that match a given selector:
ele.querySelector('div.hello');