Remove disabled attribute onClick of disabled form field

后端 未结 10 1473
眼角桃花
眼角桃花 2020-12-03 11:28

I have a form field that starts out disabled and has an onClick to enable it. The onClick doesn\'t fire (at least in FF) nor does a simple alert(1);.

The hacky vers

10条回答
  •  旧时难觅i
    2020-12-03 12:09

    Use readonly instead of disabled

    For checkboxes at least, this makes them look disabled but behave normally (tested on Google Chrome). You'll have to catch the click and prevent the default action of the event as appropriate.

提交回复
热议问题