Wednesday 15 April 2015

jquery select checkbox by div -


I'm wondering if there is a way to check / uncheck a check box in jQuery, when one of the whole devices Clicks on the layer.

Any thoughts?

Here's an example ... I'm trying to create a clickable checkbox to toggle the personal checkbox, pretty much.

& lt; Fieldset & gt; & Lt; Div & gt; & Lt; Input type = "checkbox" id = "checkbox 1" /> & Lt; / Div & gt; Person 1 & lt; Br / & gt; & Lt; / Fieldset & gt; & Lt; Fieldset & gt; & Lt; Div & gt; & Lt; Input type = "checkbox" id = "checkbox 2" /> & Lt; / Div & gt; Person 2 & lt; Br / & gt; & Lt; / Fieldset & gt;

Perhaps use the clicked div as a parent

  $ (function () {$ ('# divId'). Toggle (function) {$ (this) .find ('input'). Attr ('checked', true);} , Function (event) {$ (this) .find ('input') .ttry ('check', false);});});  

This only checks the box of #divId which has been clicked.


No comments:

Post a Comment