代码如下:

<script type="text/javascript">
window.onload=function()
{
var oIput=document.getElementsByTagName('input');
var Obtn=document.getElementById('btn');
for(var i=0;i<oIput.length;i++)
{
oIput[i].onclick=function()
{
for(var i=0;i<oIput.length;i++)
{
oIput[i].checked=false;
}
this.checked=true;
}
}
btn.onclick=function()
{

alert('提交成功');


}
}

 

布局如下:

<p>1、这周星期天你干什么?</p>
<input type="radio" />看书
<input type="radio" />睡觉
<input type="radio" />吃饭
<input type="radio" />玩耍
<input type="radio" />洗衣服
<input type="radio" />听音乐</br>
<input type="button" value="提交" id="btn" />

 

 

总结:比较遗憾的是点击提交的时候没能选出后面的文字,比如:“提交成功,这周星期天你选择看书”!

相关文章:

  • 2021-10-06
  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
  • 2022-01-01
  • 2021-10-25
猜你喜欢
  • 2021-12-22
  • 2022-12-23
  • 2022-02-11
  • 2022-12-23
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案