var listItems = $("#productList li"); listItems.each(function(idx, li) { var product = $(li); // and the rest of your code });