1. getElementById
document.getElementById ("Id_value") # return value is a node object, when no element is returned = = = undefined Value (two equals sign)
2. Getelementsbyname
Document.getelementsbyname ("Name_value") # Returns a value of NodeList array, returns an empty array when there are no elements []
3. getElementsByTagName
document.getElementsByTagName ("P") # Returns a value of NodeList array, returns an empty array when there are no elements []
4. Getelementsbyclassname
Document.getelementsbyclassname ("Class1") # Returns a value of NodeList array, returns an empty array when there are no elements []
5. Queryselector and Queryselectorall
Document.queryselector ("#id > P") # returns the first matched value, returns the value of the node object, and returns the = = undefined value when there are no elements
Document.queryselectorall ("#id > P") # returns all values, returns a value of NodeList array, returns an empty array when there are no elements []
[Timlinux] 5 ways JavaScript Gets the element node