Style display property is used to hide and show the content of HTML DOM by accessing the DOM element using JavaScript/jQuery. To hide an element, set the style display property to “none”. document. getElementById("element").
The hide() is an inbuilt method in jQuery used to hide the selected element. Syntax: $(selector). hide(duration, easing, call_function);
Apparently you can just pass a boolean to the toggle
function
$element.toggle(shouldElementBeVisible)
Yes there is!
$element.toggle();
Without any parameters, toggle
just toggles the elements visibility (I don't mean the visibility
property) and depends on the current state of the element.
$element.toggle(display);
If you call toggle
with a boolean parameter, element is shown if it is true
and hidden
if it is false
source
jQuery has toggle
: http://api.jquery.com/toggle/
$element.toggle();
This will show the element if it's hidden, and hide it if it's shown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With