In many cases, we need to get HTML elements. This post will introduce: How to use JQury to get elements by id, class, tagname, xpath?
Keywords: HTML , element , JQuery , id , class , tagname , xpath.
Import JQuery
When using JQuery to get HTML elements, you need to import the JQuery package firstly. If you do not want to download and save JQuery, you can use CDN to import. After import, we can get element by id, class, tagname and Xpath.
Id Class TagName
In JQuery, you can get elements by Id Class TagName and mixing of them. Note that the object returned by JQuery selector is an array.
Xpath
Using XPath in JQuery to select elements with a given attribute.
When we need to get elements, we can use the powerful JQuery. After importing JQuery through CDN, we can easily get elements by id, class, tagname and Xpath. If you don’t like JQuery, you can also use original Javascript to get elements. For more details, please read the related articles.