[jQuery] Re: what is the correct way to test 'display' value in jQuery?

2009-06-18 Thread mkmanning
If you're testing whether an element's display is either 'none' or 'block|inline|static|etc.' (i.e. not 'none') you can also do this: $('#subnav-1').is(':visible') or alternately $('#subnav-1').is(':hidden') Either of these returns a boolean. On Jun 17, 11:20 pm, Jake Barnes wrote: > So can

[jQuery] Re: what is the correct way to test 'display' value in jQuery?

2009-06-17 Thread Jake Barnes
So can I do this? if ($('#subnav-1').css('display') == "block") $('#subnav-1').css ('background-color', '#f00'); That is, if this element has display:block then turn the background red? Just a hypothetical example, of course. On Jun 17, 10:55 pm, Ricardo wrote: > $('#subnav-1').toggle(); >

[jQuery] Re: what is the correct way to test 'display' value in jQuery?

2009-06-17 Thread Ricardo
$('#subnav-1').toggle(); http://docs.jquery.com/Effects/toggle You can also access the display property with $('#subnav-1').css ('display'); On Jun 17, 10:02 pm, Jake Barnes wrote: > This code works, but it seems inelegant: > > if ($("#subnav-1")[0].style.display == "block") $("#subnav-1") > [

[jQuery] Re: what is the correct way to test 'display' value in jQuery?

2009-06-17 Thread Charlie Griefer
On Wed, Jun 17, 2009 at 6:02 PM, Jake Barnes wrote: > > > This code works, but it seems inelegant: > > if ($("#subnav-1")[0].style.display == "block") $("#subnav-1") > [0].style.display = "none"; > > This seems to violate The One True jQuery Way: > > [0] > > I assume I'm not suppose to do that. >