1, querySelector only return the first matching element, if there is no match, it returns null.
2, querySelectorAll return matching elements
set
, if there is no match, return an empty NodeList (node array). An element can be obtained by specifying the subject method, e.g. document.querySelectorAll ( '. Ubox') [ 0], retrieves the first.
Return result is static, after changes to the structure of the document will not affect the result to take before.
These two methods can accept three types of parameters: id (#), class, tag, like jquery selector (.).
3, getElementsByTagName () method returns the name of the object with a given label is
set .
document.getElementsByTagName("p")[3]获取指定元素。
4, getElementById () Returns the specified element.