Why doesn't jQuery.change () work when radio buttons are disabled as a result of selecting the namesake?

If I have several radio buttons with the same name, only one can be selected at any time. When someone gets out, all namesakes lose their choice. I am intrigued why this is not a .change() event for jQuery.

Hacking the $.change() function would be pretty sharp, but it doesn't seem to be reported as an error - so I'm curious to know why this isn't.

Test below: I would expect two change events to fire whenever a radio is selected, but that is not the case.

Here is an example: http://jsfiddle.net/XzmmW/

+6
source share
3 answers

If you are thinking of a set of radio buttons, such as a select element, it becomes clear why there is no need to fire a change event for the selected radio button.

When you change the selected option in the select element, you get one change event (you would not expect anything), not one for the previously selected parameter, but the other for the newly selected parameter.

As already mentioned, when one radio button is selected, there are no others in the same set, so it would be unnecessary to trigger a second change event.

Also note that this does not apply to jQuery - the standard JavaScript change event works in exactly the same way.

+11
source

There is only one change event ... you changed from "old choice" to "new choice".

Keep in mind that although you have several โ€œelementsโ€, they are all part of the same form element (as defined by the name attribute).

+2
source

There is no need to fire an event for each switch in a named group, when one is selected, you know that the others are not selected

+1
source

Source: https://habr.com/ru/post/893007/


All Articles