Now, when I click "I agree", nothing happens, I would l...">

How to check a box by clicking a label?

<input type="checkbox" /> <label>I agree</label> 

Now, when I click "I agree", nothing happens, I would like to check checked , what is the easiest way to do this?

+4
source share
2 answers

for and id attributes

 <input id="thisinput" type="checkbox" /> <label for="thisinput">I agree</label> 

http://jsfiddle.net/PNYNR/

+9
source

As an alternative to @stevether's suggestion, you can also wrap the label around the checkbox

 <label><input type="checkbox" /> I agree</label> 

http://jsfiddle.net/WDerc/

+3
source

All Articles