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.
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!