:-) Thanks for buying the book!

By the way, as John Resig can now attest, a portion of the proceeds goes right back to the jQuery project. So, thanks for helping jQuery, too. ;-)

One more thing (to avoid going totally OT):

I took the code that I wrote for you and dropped it into a page with the HTML that you provided in your last message. Looks to me like it's working just fine, but let me know if you want it to do something different.

http://test.learningjquery.com/checkboxes.html


--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On Nov 27, 2007, at 10:59 AM, jonhobbs wrote:


Hi Karl,

I've just realised where I've seen your name before. On the spine of
the spine of the book sitting here on my desk :)

An excellent book it is too.

Jon

On Nov 26, 7:09 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote:
Hi Jon,

Here you go:

$(document).ready(function() {
  $('.Grid th').each(function(column) {
    column ++;
    $('input:checkbox', this).click(function() {
      $('.Grid tbody tr td:nth-child(' + column + ')
input:checkbox').attr({checked: $(this).is(':checked') ? 'checked' :
''});
    });
  });

});

:-)

--Karl
_________________
Karl Swedbergwww.englishrules.comwww.learningjquery.com

On Nov 25, 2007, at 5:15 PM, jonhobbs wrote:



Hi,

I hope somebody can help me. I'm trying to write a function which will
tick every checkbox in a column when you tick the checkbox in the
header.

The plan is to attach an evetn to every checkbox in the header which
when you check it will find the column bumber of the cell it is in and
plug that number into the following code where the x is...

$(".Grid tbody tr td:nth-child(x)
[EMAIL PROTECTED]'checkbox']").each(function() {
      this.checked = true;
});

I can figure out how to get the parent element of the checkbox (which will be a TD), just don't know how to find out that cells position in
the table row.

Any help would be appreciated.

Reply via email to