I have:
<a class='special' href='#'>something</a>
<a class='special' href='#'>anything</a>
I need to make it with page load:
<a class='special' href='something'>something</a>
<a class='special' href='anything'>anything</a>
Something like:
$('a.special').attr('href', $(this).text());
How it can be done?
You can either run an
each()on your collection, that will set the href to the text, but a bit more elegant would be to give a function as the second parameter forattr().jsFiddle Demo