Get all anchor elements with jQuery?
I'm trying to execute some changes on ALL anchor tags. Unfortunately,
things aren't going as planned.
$('a').remove()
This line only seems to affect the first element it encounters--- if I
execute it in the console repeatedly, it progresses through the page
removing each new anchor it finds.
I want to remove them all at once. I had thought this select would affect
them all. So then I tried:
$('a').each(function(){this.remove();});
And got:
TypeError: Object [object HTMLAnchorElement] has no method 'each'
What is the correct solution to this, to execute code on all anchors?
No comments:
Post a Comment