Home > Web Front-end > JS Tutorial > jQuery uses andSelf() to include the previous selection set_jquery

jQuery uses andSelf() to include the previous selection set_jquery

WBOY
Release: 2016-05-16 16:47:46
Original
1020 people have browsed it

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

html

$lt;div$gt;
$lt;p$gt;Paragraph$lt;/p$gt;
$lt;p$gt ;Paragraph$lt;/p$gt;
$lt;/div$gt;

For the above DOM Tree, of course you can use

$('div').find ('p')

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

Usage example

For the above html code, use

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

The css effect can only be applied to p elements
jQuery uses andSelf() to include the previous selection set_jquery
But if andSelf() is added after find(), the css effect will also be applied to all div elements
jQuery uses andSelf() to include the previous selection set_jquery

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