Get a free trial // Grow your CSS skills // Land your dream job

Jquery: If ul has no li

  • # January 15, 2013 at 6:41 pm

    Hi Guys,

    I am trying to work out how to check if a UL DOES NOT contain a li … then if it is, add a message to say “sorry this is empty”.

    Any ideas?

    # January 15, 2013 at 6:55 pm

    This should do the trick

    # January 15, 2013 at 6:58 pm

    Super minor optimization:

    # January 15, 2013 at 7:07 pm

    Ah yes, this is why I refactor my code, I always miss ! vs ==0

    # January 15, 2013 at 7:23 pm

    Perfect guys. Thanks so much for your help.

    I’m new to jQuery but very quickly realising the possibilities it opens.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed