Hi, I have the below code which I believe basically says
if the div with id=“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 id=“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");
}
}
The problem is, I need this to execute on a product category page which will list an array of many products and id=“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 id=“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!