Home > Web Front-end > JS Tutorial > body text

jQuery uses andSelf() function method

巴扎黑
Release: 2017-06-24 10:35:27
Original
1993 people have browsed it

When we use Destructive Method to select and filter wrapper set, a new result set will be generated. For example:

For the above DOM Tree, of course you can use

$('p').find('p')
Copy after login

to get the p elements contained in all p elements, but the selection result will definitely not contain p element itself.
If you call andSelf() in a chain after find, you can put previous selection($(' p')) is also included in the result set.

Usage example

For the above html code, use

$('p').find('p').css('border', '1px solid #993300');
Copy after login

css effect can only be applied to the p element


But after find(), add andSelf(), css will also apply to all p elements


The above is the detailed content of jQuery uses andSelf() function method. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template