The following code this not work, because attr is undefined:
$("#foo a[href]").each(function()
{
this.attr("href", "www.google.com");
});
But this code does:
$("#foo a[href]").each(function()
{
this.href = "www.google.com";
});
Why??
You need to wrap this ... $(this)
attr is a method of a jQuery object, href is a property of an element node
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