I'm trying to move the anchor tag outside p element, currently it is inside the p element. Here is my html:
<div class="the_excerpt">
<p>
<a href="#">Learn More</a>
</p>
</div>
I have tried append()
function but it is not working. I don't want to insert new anchor element. I just want to move anchor element outside p element.
$('.the_excerpt').find('p').append($('.the_excerpt').find('a'));
Can any one please guide me how can I fix, I will appreciate. Thank You
You are trying to append inside the p
tag, since a
is inside p
it doesn't make any change for the markup. So change your code as follows
$('.the_excerpt').append($('.the_excerpt p a'));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="the_excerpt">
<p>
<a href="#">Learn More</a>
</p>
</div>
Or you need to use the appendTo()
$('.the_excerpt p a').appendTo('.the_excerpt');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="the_excerpt">
<p>
<a href="#">Learn More</a>
</p>
</div>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments