Change handler not called on radio input on Firefox

て烟熏妆下的殇ゞ 提交于 2019-12-12 06:23:23

问题


I've distilled the issue down to this jsfiddle: http://jsfiddle.net/shaggyfrog/DUqYW/3/

On Chrome/Mac and Safari/Mac, you should get the "foo" alert every time you (re)load the page.

On Firefox/Mac, the "foo" alert only comes up the first time. Subsequent reloads do not trigger it.

This is either: (A) a bug in jQuery on Firefox, where a change handler on a radio input should get called irrespective of its state when it's checked; (B) a different jQuery bug, where the change handler should not be called if it's already checked; or (C) me doing something stupid.

Is this a legitimate bug or am I a legitimate n00b?


回答1:


When you reload, Firefox preserves the checked state of radios from before the reload, so your script clicks an input that is already checked... and hence there is no value change.



来源:https://stackoverflow.com/questions/6856556/change-handler-not-called-on-radio-input-on-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!