HTML refuses to check radio button by default?

2020-03-01 06:09发布

This looks like a really basic question and I've created dozens of forms, but I just can't see what the problem is here.

I have these two radio buttons:

<input type='radio' class='free atype' value='0' name='dutch' checked='checked'/> Free<br/>
<input type='radio' class='paid atype' value='1' name='dutch' /> Paid

Obviously the first one should be checked by default.

However, when I check the second one and then refresh the page, the second radio remains checked. I know this is wrong behavior, but I can't for the life of me see what I'm doing wrong.

I'm trying this on Firefox.

标签: html forms
2条回答
Evening l夕情丶
2楼-- · 2020-03-01 06:15

Use Autocomplete="Off" as one of the properties in a tag

that will make some sense for that code.

查看更多
仙女界的扛把子
3楼-- · 2020-03-01 06:26

This is what's called auto complete, you can try to turn it off by adding the autocomplete="off" property to your inputs

<input type='radio' class='free atype' value='0' name='dutch' checked='checked' autocomplete="off"/> Free<br/>
<input type='radio' class='paid atype' value='1' name='dutch' autocomplete="off"/> Paid

You can also put it on the <form> the elements are in.

查看更多
登录 后发表回答