I am trying to figure out how to hide a button with JQuery using the .prop(hidden: true) method. For some reason, in Chrome when I set this value and view the html, the button has a hidden element, but the button still shows up as visible on the page.
Any ideas?
jQuery hide() Method The hide() method hides the selected elements. Tip: This is similar to the CSS property display:none. Note: Hidden elements will not be displayed at all (no longer affects the layout of the page).
The Best Answer is$(':checkbox'). change(function(){ $('#delete'). removeAttr('hidden'); });
Just use the function toggle() . The function toggle("slow") will show image if it hidding, and hide image if it's shown.
The toggle() method toggles between hide() and show() for the selected elements. This method checks the selected elements for visibility. show() is run if an element is hidden. hide() is run if an element is visible - This creates a toggle effect.
A button does'nt have a hidden property ?
$('button').hide();
or
$('button').toggle(true); //shows button
$('button').toggle(false); //hides button
You can use set the display
style to none
. For example,
$("#button").css("display", "none");
Or, .hide()
for brevity,
$("#button").hide()
There's also visibility
and opacity
but these two may not generate the effect you desired.
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