Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is a checkbox's click handler not fired in FF, when its label is shift clicked?

With the following code, when shift clicking the label, why isn't the checkbox's click handler fired in FF? Both Chrome and IE11 fires it.

<script>
    function show(event) {
        alert((event.srcElement||event.target).id);
    };
</script>
<input type="checkbox" id="checkbox" onclick="show(event);" />
<label for="checkbox" id="label" onclick="show(event);">Click me!</label>

Fiddle: http://jsfiddle.net/66XP4/2/

like image 349
Tamás Bolvári Avatar asked Oct 25 '25 04:10

Tamás Bolvári


1 Answers

Shift-clicking has a different default action than just clicking in Firefox. The former extends the text selection. The latter performs activation. Since activation is what fires the click on the checkbox, you're not getting a click on it. Just like you don't with a right-click on the label.

like image 198
Boris Zbarsky Avatar answered Oct 26 '25 17:10

Boris Zbarsky