本文介绍了默认情况下如何选择单选按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
我有一些单选按钮,我希望在加载页面时将其中一个设置为默认选中.我该怎么做?
I have some radio buttons and I want one of them to be set as selected by default when the page is loaded. How can I do that?
<input type="radio" name="imgsel" value="" />
推荐答案
XHTML 解决方案:
XHTML solution:
<input type="radio" name="imgsel" value="" checked="checked" />
请注意,checked 属性的实际值并不重要;这只是分配 "checked" 的约定.最重要的是,像 "true" 或 "false" 这样的字符串没有任何特殊含义.
Please note, that the actual value of checked attribute does not actually matter; it's just a convention to assign "checked". Most importantly, strings like "true" or "false" don't have any special meaning.
如果您的目标不是 XHTML 一致性,您可以将代码简化为:
If you don't aim for XHTML conformance, you can simplify the code to:
<input type="radio" name="imgsel" value="" checked>
这篇关于默认情况下如何选择单选按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
The End




大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)