Looking to add text after the 4th element in a ul li? I tried using the append function, but it's appending before every li element. Here's the HTML:
<ul class="gallery">
<li><a href="#">Some Text</a></li>
<li><a href="#">Some Text</a></li>
<li><a href="#">Some Text</a></li>
<li><a href="#">Some Text</a></li>
<li><a href="#">Some Text</a></li>
<li><a href="#">Some Text</a></li>
</ul>
Here is the jquery code I used:
$('.gallery li').each(function( index ) {
var count = 3;
if( index == count){
$( ".gallery li a" ).append('<span>Learn More</span>');
}
});
Any suggestions on how to achieve this without appending before every li element?