Now, when I click "I agree", nothing happens, I would l...">Geek Answers HandbookHow 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?+4javascript html csswong2 Oct 16 '11 at 5:13source share2 answersfor and id attributes <input id="thisinput" type="checkbox" /> <label for="thisinput">I agree</label> http://jsfiddle.net/PNYNR/+9Steve robbins Oct 16 '11 at 5:17source shareAs 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/+3Dan f Oct 16 '11 at 5:22source shareMore articles:jQuery Move div with arrows - javascriptDo suppliers of type F # 3.0 DLR use under the hood? - f #Django - Reverse Design Admin Site "Add Foreign Key" - javascriptDjango Admin - RelatedObjectLookups - How to update this and set the selection in the parent window? - javascriptWhat is an effective way to organize C ++ projects that will be tested on a module? - c ++An efficient way to merge lists of key values ββfrom character arrays - optimizationHaskell variation binding - haskellCan APL be implemented in Scala as a DSL? - scalaTinyMCE popups do not load when using S3 and setting document.domain - djangoThe inductor also delays the first pattern - c #All Articles
<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?
checked
for and id attributes
for
id
<input id="thisinput" type="checkbox" /> <label for="thisinput">I agree</label>
http://jsfiddle.net/PNYNR/
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/