I have an unordered list with several properties for each element, and I want to find all elements that have both properties.
var results = $('#mylist').find(function() { return $(this).attr('data-label') == 'red' && $(this).attr('data-size') == 1; });
I added an example to the link below:
http://jsfiddle.net/nbz4H/1/
Just use one selector:
$('li[data-label="red"][data-size="1"]').css('color','red');
Example: http://jsfiddle.net/niklasvh/RyR87/
jQuery finddoes not accept a function as a parameter. That is why it does not work.
find
You need to create the appropriate CSS selector . Sort of:
results = $('#mylist [data-label="red"][data-size="1"]');