I have used some JS which hides certain fields based upon the type it has been set using a hidden ID which then hides the field and gives it a display="none".
The problem is that I used this on one single product details page and now need to do the same concept but in a dynamic results page which has multiple id's so I'm wanting to use the same concept here so, a snippet of the code I am using is below, any tweaks/better way of being able to adapt it to be reused for multiple items on one page based upon different id's (as the different types would show on the search results page) would be much appreciated!
JS I used is here:
else if (proptype.textContent == "3628") {
document.getElementById("spbeds").style.display = "none";
document.getElementById("spbaths").style.display = "none";
document.getElementById("spbuild").style.display = "none";
document.getElementById("spterr").style.display = "none";
document.getElementById("sppool").style.display = "none";
document.getElementById("sp2beds").style.display = "none";
document.getElementById("sp2baths").style.display = "none";
document.getElementById("sp2build").style.display = "none";
document.getElementById("sp2terr").style.display = "none";
document.getElementById("sp2pool").style.display = "none";
}
Which results to:
<div class="property-amenities hidden-sm hidden-xs clearfix">
<span><strong>00RN4</strong>Reference</span>
<span id="sp2beds" style="display: none;"><strong>0</strong>Bedrooms</span>
<span id="sp2baths" style="display: none;"><strong>0</strong>Bathrooms</span>
<span id="sp2build" style="display: none;"><strong>0m²</strong>Build</span>
<span id="sp2terr" style="display: none;"><strong>0m²</strong>Terrace Size</span>
<span id="sp2plot"><strong>0m²</strong>Plot</span>
<span id="sp2pool" style="display: none;"><strong>No</strong>Pool</span>
<span id="sp2zone"><strong>None </strong>Planning Zone</span>
<span><strong>150.000€</strong>Price</span>
</div>
document.getElementsByClassNameordocument.querySelectorAllto get a list; iterate through the list, setting the style you want. See stackoverflow.com/q/35458972/215552