Home  >  Article  >  Web Front-end  >  How to get elements with jquery

How to get elements with jquery

coldplay.xixi
coldplay.xixiOriginal
2020-11-13 16:23:2012939browse

Jquery method of obtaining elements: 1. Use the function [$("div")] to obtain it directly through the element name; 2. You can add a class to the element; 3. Use [$(".bd") 】You can also get div elements.

How to get elements with jquery

Recommendation: "jquery video tutorial"

Jquery method of obtaining elements:

1. As shown in the figure, for example, we want to get or get this div element.

How to get elements with jquery

#2. We can do this, use $("div"), which is to get it directly through the element name, be careful to add quotation marks.

How to get elements with jquery

#3. Or you can add a class to the element, as shown in the picture, I added a bd class.

How to get elements with jquery

#4. Then we can also get the div element with $(".bd"). Note that the class name requires a dot.

How to get elements with jquery

#5. In addition, id is also a good method, but there can only be one id and no duplicate names.

How to get elements with jquery

#6. As shown in the figure, the id in jQuery must be added with a # sign to be valid.

How to get elements with jquery

#7. Finally, I will sort out some of the more commonly used methods of obtaining elements in jQuery.

How to get elements with jquery

The above is the detailed content of How to get elements with jquery. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn