Need to disable an input when the check-box is unchecked, and when it is checked enable it.
My code is like this:
<div class="y">
<input type="checkbox" class="myCheck" />
<input type="select" name="x" class="mySelect" />
</div>
<div class="y">
<input type="checkbox" class="myCheck" />
<input type="select" name="x" class="mySelect" />
</div>
<div class="y">
<input type="checkbox" class="myCheck" />
<input type="select" name="x" class="mySelect" />
</div>
But I want to disable and enable the select input which correspond to a check-box. If user clicks in first check box enable first input, and do the same for second and third.
If you want to go the pure CSS route, you can write CSS that changes the
opacity
andpointer-events
when the checkbox sibling is unchecked.Tab Issue
In order to stop someone from tabbing into the input, you can add
tabindex="-1"
to the input.One simple solution:
References
.next()
.prop()