Hi, I have the below code which I believe basically says if the div with class="sectionavailability" equals "in stock" replace with SOME HTML or if it has "out of stock" replace with SOME OTHER HTML Works great, but only executes once on a page, the first occurance of class="sectionavailability" if(jQuery(".sectionavailability").length){ if(jQuery(".sectionavailability").text().toLowerCase() === "in stock"){ jQuery(".sectionavailability").html("SOME HTML CODE HERE"); } else if(jQuery(".sectionavailability").text().toLowerCase() === "out of stock"){ jQuery(".sectionavailability").html("SOME OTHER HTML CODE HERE"); } } Code (markup): The problem is, I need this to execute on a product category page which will list an array of many products and class="sectionavailability" will occur many times. How does the above code need to be altered to have it execute more than once on a page, whenever class="sectionavailability" is found? I know perhaps this is involved each(function() ? But I have no idea how to alter the code to include it.... Can someone help make the above if statement work more than once on a page please? Thanks!
Hi I think you want something like this... jQuery(".sectionavailability").each(function(){ // your code here if(jQuery(this).length){ if(jQuery(this).text().toLowerCase() === "in stock"){ jQuery(this).html("SOME HTML CODE HERE"); } else if(jQuery(this).text().toLowerCase() === "out of stock"){ jQuery(this).html("SOME OTHER HTML CODE HERE"); } } } }); Code (markup): So really you just replace jQuery(".sectionavailability") with jQuery(this) inside the each function. I don't have time to check I got that right but it's in the jQuery docs if what I wrote doesn't work. Good luck with it!