Radio Button change event not working in chrome or

2020-04-21 06:23发布

I've got some radio buttons on a page and when Yes is selected, some other controls (dropdowns and textboxes) become visible. If No is selected, they become invisible again. This is working fine in FF & IE. It does work when I use the mouse with chrome, but when I'm tabbing through the page, the controls never become visible. It's as if the change event doesn't trigger because I'm tabbing. Any ideas of what might be causing this, or how I'd go about fixing it?

The show/hide functionality is being done with JQuery.

Edit: Showing the code that is giving problems.

$("#rbtnControlYes").change(function () { $("#otherControls").show(); });

2条回答
该账号已被封号
2楼-- · 2020-04-21 07:10

For those not using JQuery, the onClick event is what you want.

It appears that onClick has the behavior of what we intuitively call "select". That is, onClick will capture both click events and tab events that select a radio button. onClick on Chrome

onClick has this behavior across all browsers (I've tested with IE 7-9, FF 3.6, Chrome 10, & Safari 5).

查看更多
三岁会撩人
3楼-- · 2020-04-21 07:13

Found the answer to this.

Instead of using the .change event, I switched it to .click and everything worked fine.

Hope this helps someone.

Slap

查看更多
登录 后发表回答