I have a blob of HTML. How can I use jQuery to remove the class attribute from all anchor tags in the blob and then return the resulting HTML?
I feel like this should work, but it doesn’t:
$(blob).filter('a').removeAttr('class').end().html()
(It returns the empty string)
Bonus points if you explain why my solution is wrong.
You want this:
.filter()takes the selected elements and removes all those that aren’t<a>tags..find()traverses into the entire tree, finding all anchor tags inside.