var c = 0; $("body").find("ul#list li").each(function () { if (this.className == "now") alert(c); c++; });