Imagine I have a collection of .item
divs. Each with it's own data-item-id
attribute. I want to check if any of the .data .items
has a data-item-id
equal to x
.
Because if any of the items have that id, I will not be adding that .item
again to the .data
listing div.
How can I do this using jQuery?
if ($('.data .items').data('itemId')) { ????
}
This should return items where data-item-id is equal to x:
or like this:
And in an if: