Creating a dynamic price estimator.
I need help writing a jQuery function that can hide or show a specific div element based on the value of a variable.
For example, let's say I have an HTML div with the ID 'Answer':
<div id="answer">Hide Me</div>
$("#answer")...
And a variable called x:
var x = 30
To hide the div using CSS:
#answer{
visibility:hidden;
}
How can I create a function that checks if x is greater than 20 and hides the div accordingly?
I understand there are multiple ways to achieve this and it may not necessarily require jQuery. If there is a different approach using JavaScript alone, please share as I am eager to learn.
Any guidance would be appreciated.
Thank you!