MDN - Attributes says:
A
<label>
can be associated with a control either by placing the control element inside the element, or by using thefor
attribute.
I was checking a demo for Animated Checkbox with CSS3 Powered Animation. I tired to make it as label with input element inside it, based on Possible to associate label with checkbox without using "for=id"?.
When I made the change, the checkbox is not working. Why is it not working after this change and how to fix this?
Working: https://codepen.io/anon/pen/LLPQoy
Not Working: https://codepen.io/anon/pen/qjWodj
Note: I cannot use "For" attribute in label since the input elements will be dynamically added in my actual HTML page.
HTML
<div class="myDiv" style="padding:20px 0 20px 20px;">
<input type="checkbox" id="cbtest" />
<label for="cbtest" class="check-box"></label>
</div>