Wednesday, 21 August 2013

jquery : how to intersect two data-attribute selector queries

jquery : how to intersect two data-attribute selector queries

I've got some DOM elements with attributes data-foo and data-bar.
Is there an elegant way to return only those elements that match on both
attributes ?
At the moment I'm just using a filter, but maybe there's a better way
var result = $('[data-foo="aaa"]').filter('[data-bar="bbb"]');

No comments:

Post a Comment