Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding button in JQuery using .prop(hidden: true)

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?

like image 601
2scottish Avatar asked Feb 15 '13 17:02

2scottish


People also ask

Is jQuery hide () is equivalent to?

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).

How can remove hidden property in jQuery?

The Best Answer is$(':checkbox'). change(function(){ $('#delete'). removeAttr('hidden'); });

How do you hide an image on a button click using jQuery?

Just use the function toggle() . The function toggle("slow") will show image if it hidding, and hide image if it's shown.

How do I toggle Show hide in jQuery?

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.


2 Answers

A button does'nt have a hidden property ?

$('button').hide();

or

$('button').toggle(true);  //shows button
$('button').toggle(false); //hides button
like image 140
adeneo Avatar answered Sep 19 '22 21:09

adeneo


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.

like image 20
Alexander Avatar answered Sep 21 '22 21:09

Alexander