I want to be able to change all the anchor's properties on a page. But I don't know how to loop through all of them.
use each:
http://api.jquery.com/each/
$("a").each(function(){
//do something with the element here.
});
You can use .attr()
with a function to change a specific property, for example:
$("a").attr("href", function(i, oldHref) {
return oldHref + "#hash";
});
This is cheaper than .each()
since you're not creating an extra jQuery object inside each iteration, you're accessing the properties on the DOM element without doing that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With