Jquery click check nearest checkbox

Viewed 25775

I'm trying to use a link to check a checkbox with jQuery. My HTML is:

<table>
  <tr>
    <td><input type="checkbox" value="test" /></td>
    <td><a class="editbutton" href="#">edit</a></td>
  </tr>
</table>

I have been playing with this jquery:

jQuery('.editbutton').click(function($) {
    jQuery(this).closest('[type=checkbox]').attr('checked', true);
});

Unfortunately this isn't working. Any ideas?

1 Answers
Related