jimjim
jimjim

Reputation: 2503

Select all the elements within an element having an attribute set to a specific value

I have the followings defined :

var excludedFiltersPanel = $("#excludedFiltersPanel");
var includedfiltersPanel = $("#includedfiltersPanel");

where *Panel is just a div.

in excludedFiltersPanel there are some div's with attribute data-iscorefilter="true" e.g. :

<div id="filterPanel-LastName" class="filterPanel" data-iscorefilter="true">
  <Some Stuff here!>
</div>

I am trying to get them and move them to includedfiltersPanel:

It seems neither of these is a correct syntax:

1.What is the correct syntax?

2.How do I append them to includedfiltersPanel? (I know how to append a single item, but not sure what is the common good practice here, e.g. using for loop or some JQuery magic)

Upvotes: 0

Views: 29

Answers (1)

guradio
guradio

Reputation: 15555

Since excludedFiltersPanel there are some div's with attribute data-iscorefilter="true"

Use .find()

Description: Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.

It would look like :

excludedFiltersPanel.find('[data-iscorefilter="true"]')

Upvotes: 2

Related Questions