Use the descendant selector.

Div ul li
Vs
Div ul > li 

The > says only the first instance of that object.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Dan Eastwell
Sent: Wednesday, March 14, 2007 10:01 AM
To: jQuery Discussion.
Subject: [jQuery] Selecting only one level in DOM and no deeper

I have a function

function closeSubModules(subModules){
        for(var i=0; i < subModules.length; i++){
                theElement = subModules[i];     
                $(theElement).hide();
        }       
}

one of the subModules[i] I've passed this function in an array is "#faq li
ul" and hides all the sub-modules e.g.

<div id="faq">
    <ul>
        <li>
            <ul> <!-- hide this -->
               ....
            </ul>
        </li>
    </ul>

I've another function that toggles the hidden submodules onclick of another
element on the page.

If the submodule has a list inside it (e.g. as bullet points within some
text) these get hidden by closeSubModules() but don't get shown by the
toggle function (that only targets the "#faq li ul" level and no deeper).

I've added this to my toggle function,

$(theItems).children("ul").show();

but that is a bit of a hack and only goes one level deep, and won't show
nested lists within any text in the module.

Any thoughts?

Thanks,

Dan.

--
Daniel Eastwell

Portfolio and articles:
http://www.thoughtballoon.co.uk

Blog:
http://www.thoughtballoon.co.uk/blog

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/



_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to