HTML拒绝默认检查单选按钮? [英] HTML refuses to check radio button by default?

查看:94
本文介绍了HTML拒绝默认检查单选按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这看起来像是一个非常基本的问题,我创建了几十个表单,但我无法看到问题在这里。



我有这些两个单选按钮:

 < input type ='radio'class ='free atype'value ='0'name =' dutch'checked ='checked'/>游离LT峰; br /> 
< input type ='radio'class ='paid atype'value ='1'name ='dutch'/>付款

显然,第一个应该默认检查。



然而,当我检查第二个,然后刷新页面时,第二个广播仍然被检查。我知道这是错误的行为,但我不能为我的生活看到我做错了什么。



我在Firefox上试着这样做。

这就是所谓的自动完成,你可以尝试通过添加 autocomplete =off来关闭它。


解决方案

property to your input

 < input type ='radio'class ='free atype' value ='0'name ='dutch'checked ='checked'autocomplete =off/>游离LT峰; br /> 
< input type ='radio'class ='paid atype'value ='1'name ='dutch'autocomplete =off/>付款

您也可以将它放在< form> 元素都在。


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.

解决方案

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.

这篇关于HTML拒绝默认检查单选按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆