jquery - How to add dynamically class to single < li> when using in Loop -
i have created pagination using for-loop, using jquery how add dynamically class < li>. here code:
echo "<ul class='pagination'>"; for($i=1; $i<=$number_of_pages; $i++) { echo "<li id='add_class'>"."<a href='first_year.php?p=$i'>".$i."</a>"; } echo "</ul>";
you can below. consider want add active
class
add class first li element
$("ul.pagination > li:first").addclass("active");
add class nth position element (for example position 5, need pass 4 index)
$("ul.pagination > li:eq(4)").addclass("active");
if want add class element
$("ul.pagination > li").addclass("active");
Comments
Post a Comment