Reputation: 127
I'm sorry for stupid title.
Problem: I need to select only .special element from $elements variable.
<div class="element"></div>
<div class="element special"></div>
<div class="element"></div>
Jquery:
var $elements = $('.element'),
$special = $element.find('.special'); // Not working.
UPD: Please, don't write something like "$('.element.special')". It's wrong for my case.
Upvotes: 0
Views: 93
Reputation: 447
< div class="element">bbb< /div>
< div class="element special">aaa< /div>
< div class="element">aaa< /div>
var $special = $('.element.special');
$special.html("test");
Upvotes: 3
Reputation: 388366
You need to use .filter()
var $elements = $('.element'),
$special = $element.filter('.special');
Since the element you are targeting is a member of the $element
set, you need to use .filter()
, .find() is used to find descendant members of the elements in the calling set
Upvotes: 9