The simplest method would be to use the optional context parameter of the
jQuery call.

var $list = $('#li_id');

$('ul',$list);



-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Giovanni Battista Lenoci
Sent: Thursday, September 13, 2007 8:22 AM
To: jQuery (English)
Subject: [jQuery] Find a specific children in a jquery object


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