Onno Timmerman schrieb:
> Hi,
>
> I was wondering how do you put if else situations in Jquery. For example:
>
> if ($(div.foo).css("display") == "none")
>       {
>       do this
>       }
> else
>       {
>       do that
>       }
>
> If something is open it needs to be closed first before something else 
> will be openend. I have problems to get this in clear code. Maybe it 
> could be taken up in the tutorial?
>   
May 'is(String expression)' is what you are looking for. You could 
rewrite your if statement to this:
if( $('div.foo').is(':hidden') ) {
    foo();
} else {
    bar();
}

There have been attemps to implement if/else methods into jQuery. But in 
most cases, plain if/else statements with more sophisticated expressions 
should suffice.

-- Jörn

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to