Im finding jQuery to difficult to learn as there seems to be many ways to write the same thing.
As an exercise I would like to take the text within anchor tags and stuff it into the links href attribute.
eg
<a href="">http://www.something.com</a>
to become
<a href="http://www.something.com">http://www.something.com</a>
my first attemp was
<script type="text/javascript">
$(document).ready(function() {
var text = $('a').text();
$('a').attr( 'href', text );
});
</script>
which clearly doesnt work as I need to specify to do this action for each link.
Should I use a foreach loop? A .each() function? Or $this notation? Would they all work?