Anyway to programmatically hide a jQuery UI button?

neezer picture neezer · May 6, 2011 · Viewed 8.7k times · Source

I'd like to do something like this, with jQuery UI Button:

$button.button();
// ...
$button.button('hide');
// ...
$button.button('show');

Similar to how enable/disable works. Hiding and showing the button manually ($button.hide(); $button.show();) is resulting in some really screwy formatting with the jQuery UI CSS...

Am I missing something simple here?

Answer

jcvandan picture jcvandan · May 6, 2011

Just doing the standard $button.hide() should do the job fine, what exactly is it screwing up?

You could do $button.css('display', 'none') but this is all that $button.hide() does anyway.

I'm pretty sure there isn't a way to do what you ask, and even if there would it only set display: none like the methods I just mentioned. You might be better of figuring out why setting display none is screwing up your CSS elsewhere on the page.