我想寫一個jquery調用來選擇複選框ul菜單的「孩子」和「父母」,當用戶選中框。jquery幫助同時選擇父母和孩子,但不是祖先的兄弟姐妹
這jquery適當地選擇父母和孩子,但它也是通過父母穿越時選擇兄弟姐妹。
//Check the Parents
$(this).parents().find("input").checkUncheck(true);
//Check the Children
$(this).parent().siblings("ul").find("input").checkUncheck(true);
我不希望它遍歷祖先時選擇了「父母」選擇兄弟姐妹,但我不知道該怎麼辦了jQuery。如果任何人有關於如何做到這一點的一些提示,我將不勝感激!
謝謝。
繼承人的HTML:
<ul id="p_menu_nav">
<li>
<span>
<input type="checkbox" title="no">
<img images/minus.gif" class="a_hand"> Wells Fargo
</span>
<ul >
<li >
<span>
<input type="checkbox" title="no">
<img src="images/plus.gif" class="a_hand"> Southern Utah
</span>
</li>
<li >
<span>
<input type="checkbox" title="no">
<img src="images/plus.gif" class="a_hand"> Northern Utah
</span>
</li>
<li >
<span>
<input type="checkbox" title="no">
<img images/minus.gif" class="a_hand"> Central Utah
</span>
<ul >
<li>
<input type="checkbox" name="approved_property_id_list" id="4835">Apartment 1
</li>
<li>
<input type="checkbox" name="approved_property_id_list" id="4844">Apartment 10
</li>
<li>
<input type="checkbox" name="approved_property_id_list" id="4934">Apartment 100
</li>
</ul>
</li>
</ul>
</li>
</ul>
你可以通過解釋究竟應該得到選中/取消和選擇複選框時澄清?我已經讀了五次這個問題,似乎無法得到它(也許這只是我:) – karim79 2011-03-28 23:26:24