Home  >  Article  >  Web Front-end  >  jQuery uses andSelf() function method

jQuery uses andSelf() function method

巴扎黑
巴扎黑Original
2017-06-24 10:35:271954browse

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')

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');

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!

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