Monday, 9 September 2013

jQuery if any item in collection has data-id equal foo

jQuery if any item in collection has data-id equal foo

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')) { ????
}

No comments:

Post a Comment