Mark the checkbox by clicking in the row or on the button

The question was asked: 6 years 11 months ago   views: 17

Good time of day, gentlemen.

  1. Have a table inside a table in one of the cells checkbox. I want to when clicking on the row to activate/deactivate it (like in phpmyadmin). In the Internet there are a couple of decisions on this subject, but unfortunately they need to add a class that I'm busy. Are there alternative methods?
  2. Is it possible when you click on the button to mark a checkbox? Or more? (ie only tag, when you press that mark does not fly)
Asked: angry angry 21-06-2012 в 18:29:31
if I'm not mistaken, the element can be several classes listed, separated by spaces. - system29a system29a 21-06-2012 в 20:17:35
You want using pure javascript or ready to use frameworks (e.g. jquery) ? - Чад Чад 21-06-2012 в 21:31:22
Yes, I do have what may be an example. adequate. then I firstly apply, and secondly a lot to learn. - Sergey Sergey 21-06-2012 в 23:52:47

Answers   2

Чад Чад22-06-2012 в 14:14:07

If jquery it is possible:

 $(this).find(":checkbox").attr("checked","checked");//deselect all checkboxes in the clicked container, deselect using removeAttr("checked")


html do something like:

<tr class="RowClass"><td><input type="checkbox"/></td><td></td></tr>

you can not table a wonder or anything else. The bottom line is that we are hung up on the elements with the class and looking for by clicking inside the checkboxes...

in order to remove/put - complicate the function of a click - add say $(this).attr("state") - the desired state and based on that remove or send checks (don't forget to update the attribute state)

Yes, in the current implementation is feature - when clicking on the checkbox will work as well click and set all the check boxes. I think I will figure out how to avoid it - the mass of options. But if failed, please, tell me.

Answered: Чад Чад 22-06-2012 в 13:42:12
did just that. although the code themselves, and not on the dream. eat, but JQ hooked. I have not worked. now understand, in what business - Sergey Sergey 22-06-2012 в 14:07:46
Sealed, class tr naturally

Chikitsa and Vice versa will be anyone to do the reaction on the area of the wrap check in the label that is something like: <label for="check1"><input id="check1" type="checkbox" /></label>

Answered: Michael Michael 22-06-2012 в 13:28:20
works, but if input is inside label - not working 8-( - Sergey Sergey 22-06-2012 в 13:50:09