LocalHorst
LocalHorst

Reputation: 1168

Why does triggering a 'click' result in a different Event on radioButton and Checkbox?

Triggering a click Event on a Radio Button and a Checkbox results in a slightly different result when you look at the event thta is triggered:

So triggering click on a RadioButton by doing

$('#radio01').trigger('click');

and catching the event on the radio button by

$('#radio01').on('click', reactToClick);

function reactToClick(event) {
    console.log(event);
}

Shows me a different result then doing the same on a checkbox:

$('#myCheckbox').trigger('click');

&

$('#myCheckbox').on('click', reactToClick);

function reactToClick(event) {
    console.log(event);
}

The Checkbox & RadioButton look like this:

<input type="checkbox" id="myCheckbox" name="checkme" />
<label for="myCheckbox">Check Me</label>

<input type="radio" id="radio01" name="radio" value="0" />
<label for="radio01">Option 1</label>

You can see the different output in this Plunkr i created to visualize the problem. Can anyone tell me why it behaves differently?

EDIT: As some answers came already, this is what happens in my browser when i click on those Trigger-Buttons in the Plunkr: enter image description here

Upvotes: 0

Views: 94

Answers (0)

Related Questions