or try

ndfs=$('#no-defs');($('.def').length == 0) ? ndfs.show() : ndfs.hide();

> Date: Thu, 16 Apr 2009 13:54:07 -0700
> Subject: [jQuery] Re: Shorten the JQuery code
> From: morni...@gmail.com
> To: jquery-en@googlegroups.com
> 
> 
> There isn't much you can do with that since you can't conditionally
> code in ".show" or ".hide" unless you made a plugin to pass in a true/
> false parameter and decide in the plugin, for instance
> 
> $("#no_defs").conditionalShow($('.def').length == 0);
> 
> 
> 
> On Apr 16, 4:27 pm, Dragon-Fly999 <dragon-fly...@hotmail.com> wrote:
> > Could someone tell me how to shorten the following code? Thanks.
> >
> >           if ($('.def').length == 0) {
> >             $('#no-defs').show();
> >           }
> >           else {
> >             $('#no-defs').hide();
> >           }

_________________________________________________________________
View your Twitter and Flickr updates from one place – Learn more!
http://clk.atdmt.com/UKM/go/137984870/direct/01/

Reply via email to