百科知识

通过JS代码获取复选框的选择项中要用到哪些主要代码?

2018-10-27 21:02:57我***
通过JS代码获取复选框的选择项中要用到哪些主要代码?通过JS代码获取复选框的选择项中要用到哪些主要代码?:【实例代码】html xmlns=http://www.w3.org/1999/xhtml headtit?

最佳回答

  •   【实例代码】html xmlns=http://www。w3。org/1999/xhtml headtitle标题页-学无忧(www。xue51。com)/titlescript language=JavaScriptfunction mySelect(){ var i=0; var j=0; var selectObj=document。
      getElementsByName(love); //遍历复选框的选择 for (i=0;iselectObj。length;i++) { if (selectObj[i]。checked) { j=1; break; } } if (j!=1) { alert(请选择至少一种爱好!) return false; } alert(selectObj[i]。
      value);//显示所选择的第一项的内容}/script/headbodyform name=form1input type=checkbox name=love value=旅游 旅游input type=checkbox name=love value=体育 体育br/input type=checkbox name=love value=购物 购物input type=checkbox name=love value=影视 影视input type=checkbox name=love value=音乐 音乐input type=button value=我的选择 onclick=mySelect()/form/html。
      
    2018-10-27 22:06:57
  • 很赞哦! (113)