I’ve built this site www.piano-warehouse.co.uk/category/upright-pianos/ using WordPress and have utilised a plugin for calculating the amount of money saved if a discount has been applied to a product. I would like to modify the setup so that if no discount has been applied and there is no amount saved to hide the you save section. I assume javascript or jQuery will be the ticket however I have a very elementary understanding of these languages and would really appreciate any help with constructing this query.
So far I’ve tried adding this to my functions file with no joy
function you_save_hide () {
if ($("span.yousave_list_price").text() == "0") {
$("span.yousave_list").hide();
}
}
From the link I can see if
$("span.yousave_list_price")
contains another DOM elementSo if you are looking to hide this
span.yousave_list_price
you may have to do like thisJSFIDDLE
you must ensure that the page is ready when calling this function
I checked your website, span.yousave_list_price is the next element to span.yousave_list and I am sure you didn’t wish to hide all the span.yousave_list of 0. But only those which has span.yousave_list_price. So we will select all the span.yousave_list_price -> check if the text is 0 -> then we select it’s parent and -> within the parent we hide the span.yousave_list.
if you are executing this function on page load then be sure to call it within
$(document).ready(function(){...}