you can use the ":has()" selector
ex. $(this).parent(":has(ul)")  will return the parent if it has an
"ul"


On Sep 13, 3:21 pm, Giovanni Battista Lenoci <[EMAIL PROTECTED]>
wrote:
> Hi, if I want to get the ul childrens of a li element I do something
> like this:
>
> $('#li_id ul')
>
> But If I have already the jquery li object how can I do this without
> getting the id of the element?
>
> More in specific, I click on a checkbox, then I get the container
> (which doesn't have an id) with parent() method, then I want to know
> if in the parent exist an ul element.
>
> <ul>
> <li>
>   <input type="checkbox" id="check1" value="1" name="test"
> class="checkall" />
> </li>
> <li>
>   <input type="checkbox" id="check2" value="1" name="test"
> class="checkall" />
>   <ul>
>      <li><input type="checkbox" id="check3" value="1" name="test"
> class="sub_check" /></li>
>      <li><input type="checkbox" id="check4" value="1" name="test"
> class="sub_check" /></li>
>   <ul>
> </li>
> </ul>
>
> then in jquery I do:
>
> $('.checkall').bind('click', function () {
>   parent_li = $(this).parent()[0];
>   // now I want to know if parent li has ul inside.
>
> });
>
> Thank you

Reply via email to