WARNING:
THIS CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED; THE AUTHOR DISCLAIMS ALL LIABILITY FOR ANY DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR STORE DISRUPTIONS ARISING FROM ITS USE.
Scot Ranney • August 15, 2024
Clicking on the text next to a checkbox should always check the box, but if you can't use FOR in the label tag to point to the checkbox input ID, there is a simple hack to get around this. Simply put everything you inside the label tag, including the input.
FOR
ID
In these example, clicking on the text, images, etc, will cause the checkbox to be checked.
<label> Click me to check the box. <input type="checkbox"> </label> <label> <input type="checkbox"> Click me or this image <img src="image.png"> to check the box. </label>
Etc.
checkbox input