JS get document.getElementsByTagName (tagname)
The order in which the getElementsByTagName () method returns elements is the order in which they are in the document.
If you pass the special string "*" to the getElementsByTagName () method, it returns a list of all the elements in the document, and the order in which they are arranged is the order in which they are in the document.
The code is as follows |
Copy Code |
var tables = document.getelementsbytagname ("table"); Alert ("This document contains" + Tables.length + "tables"); |
jquery Get TagName
If you want to make a judgment after tagname, it is easier to use the following code directly:
The code is as follows |
Copy Code |
$ (Element). Is (' input ') |
If you want to take the label as a place to go, you can use the code:
The code is as follows |
Copy Code |
$ (Element) [0].tagname Or: $ (Element). Get (0). tagName
|