I want to move the value of href from one link to another using jQuery.
I have it selected, but I am having trouble injecting it into the new ancor tag. Is there a better way to do this?
HTML:
<ul class="menu">
<li><a href="1">1</a></li>
<li><a href="2">2</a></li>
<li><a href="3">3</a></li>
<li><a href="4">4</a></li>
<li class="active"><a href="5">5</a></li>
<li><a href="6">6</a></li>
<li><a href="7">7</a></li>
<li><a href="8">8</a></li>
</ul>
<a class="GO!" href="">go!</a>
jQ:
var goLink = $('li.active > a').attr("href");
$(.go).attr("href", 'golink');
you cannot have a class called
GO!so change it to:jQuery:
DEMO JSFIDDLE