Reputation: 943
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?
Upvotes: 1
Views: 863
Reputation: 1039200
You could use the .filter()
function:
var elements = $('.my_class');
var filtered = elements.filter('[href]');
Upvotes: 5