views:

15

answers:

1

So if I were to do this $('.my_class[href]'), this should return to me all the elements in the page with class 'my_class' that has attribute 'href'.

Could I get to the same result if I have a variable with the value $('.my_class')? How do I filter only those elements in that variable with those who have attributes?

+1  A: 

You could use the .filter() function:

var elements = $('.my_class');
var filtered = elements.filter('[href]');
Darin Dimitrov
perfect! thanks. i was looking for that, but couldnt find it