I need to append some text after the 4th element inside ul li so I am using the append function for it. The problem is if the statement not working inside .each function and it is appending before every li element.
Here is HTML markup
<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
$('.gallery li').each(function( index ) {
var count = 3;
if( index == count){
$( ".gallery li a" ).append('<span>Learn More</span>');
}
});
What is the problem is there any other way to achieve this?