I'm one step closer ;]. I'm traversing from tr not from td. And it seems to work fine except that now the checkbox itself doesn't have the ability to check or uncheck so i've tried to add some more code ([1]) but then I have to doublecklick it to check or unckeck =/ weird...
my code: --- var tr = $(".myTable tr") tr.click(function(){ var input = $("input[type=checkbox]", this); input.attr('checked', !input.attr('checked')); /* [1] */ input.click(function(){ $(this).attr('checked', !$(this).attr ('checked')); }); }); ---- please help. On Feb 1, 12:10 am, Slafs <slaf...@gmail.com> wrote: > Hi! > > I would like to write a js script using jQuery which could help me to > toggle checkbox. > I have one checkbox for each row of table and i would like to simplify > the checking and unchecking the boxes by letting user just to click > anywhere on the row to do this. > I was trying something with children and parent function but it seems > to doesn't work. > > table: > <table class="myTable"> > <tr> > <td>first</td><td>row</td> > <td><input type="checkbox" name="1" value="1"></td> > </tr> > ... > </table> > > my jQ code: > $(document).ready(function(){ > $(".myTable td").click(function(){ > $(this).parent("tr").children > ("input:checkbox").each(function(){ > this.checked = !this.checked; > }); > > }); > > any help? > thanks in advance!