Online demonstrationhttp://demo.jb51.net/js/2012/jquery_demo/jQuery basic selector example.html Hierarchical selector If you want to pass the DOM To obtain specific elements based on the hierarchical relationship between elements, such as descendant elements, child elements, adjacent elements, sibling elements, etc., then the hierarchical selector is a very good choice.
The rules for hierarchical selectors are as follows:
You can use the next() method to replace the $("prev next") selector, that is, $(".one div") is equivalent to $(".one").next("div") .
You can use the nextAll() method to replace the $("prev~siblings") selector, that is, $(".one~div") and $(".one").nextAll("div") Equivalent.
Summary This article mainly introduces the basic selectors and hierarchical selectors in jQuery selectors, and gives sample code for each type of selector. I hope it will be helpful to everyone. I am also a beginner of jQuery, so everyone is welcome to try it out.
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