How to Find Out Last Index of each() in jQuery?
Remember to cache the selector $("ul li")
because it's not cheap.
Caching the length itself is a micro optimisation though, that's optional.
var lis = $("ul li"), len = lis.length;lis.each(function(i) { if (i === len - 1) { $(this).append(";"); } else { $(this).append(","); }});