checkbox - Sub selecting (checking) checkboxes that have a specified tag in Jquery -



checkbox - Sub selecting (checking) checkboxes that have a specified tag in Jquery -

i have tricky jquery question; want able select childs of specific checkbox when has span class identer , content '-- '

in illustration below; want when check 'alarme' both 'alarmes domestiques' , 'contrôle d'accès' checked; reverse action when unselect it.

must damn easy i'm not jquery expert.

thanks !

i have next code :

<tbody> <tr class="odd"> <td> <div class="form-item-2-0-checkboxes-1--1"> <input type="checkbox" name="2[0][checkboxes][1][-1]" value="1"> </div> </td> <td> <span class="indenter"></span> <a href="/taxonomy/term/1" class="depth-0">alarmes</a> </td> </tr> <tr class="even"> <td> <div class="form-item-2-0-checkboxes-4--1"> <input type="checkbox" name="2[0][checkboxes][4][-1]" value="1"> </div> </td> <td> <span class="indenter">--&nbsp;</span> <a href="/taxonomy/term/4" class="depth-1">alarmes domestiques</a> </td> </tr> <tr class="odd"> <td> <div class="form-item-2-0-checkboxes-5--1"> <input type="checkbox" name="2[0][checkboxes][5][-1]" value="1"> </div> </td> <td> <span class="indenter"></span> <a href="/taxonomy/term/2" class="depth-0">aménagement</a> </td> </tr> <tr class="even"> <td> <div class="form-item-2-0-checkboxes-3--1"> <input type="checkbox" name="2[0][checkboxes][3][-1]" value="1"> </div> </td> <td> <span class="indenter"></span> <a href="/taxonomy/term/3" class="depth-0">sanitaires</a> </td> </tr> </tbody>

ok, seek that, not nice code yet.

$checkboxes = $("span.indenter:empty").parent().prev().children().children(); $checkboxes.click(function(){ var $t = $(this); var checked = $t.is(':checked'); var $tr = $t.parent().parent().parent(); var child; { $tr = $tr.next(); if(!$tr.length) return; kid = ! $tr.children(":nth-child(2)").children("span").is(":empty"); if( kid ) $tr.children(":nth-child(1)").children().children().prop('checked',checked); } while(child); });

jquery checkbox

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -