If you click on the label in the example below, it will change the state of the input.
document.querySelector("label").addEventListener("click", function() {
console.log("clicked label");
});
label {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
<input type="checkbox" id="1">
<label for="1">Label</label>
In Chrome, even when moving the cursor between the mousedown
and mouseup
events, the input still triggers. However, in Firefox, the checkbox does not change state.
Is there a solution to this issue without relying on JavaScript event listeners?
Firefox version: 69.0.3 (64-bit)
Complete sequence of actions in Chrome:
- Click on the label
- Move the cursor around while holding the button (even outside the label area)
- Bring the cursor back to the label
- Release the button