为了账号安全,请及时绑定邮箱和手机立即绑定

关于数组和复选框的结合问题

关于数组和复选框的结合问题

Einson 2016-07-11 17:10:29
怎么做才能让每个数组后面出现一个复选框? <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <title>Document</title>     <script>         var arr=["别称","医术","称为","高手","密切","其中","动人","疑难杂症","行医","当地","其他","苏醒"  ,"康复","高明","病情","治愈","成熟","闻","谷子","仓库","堆","宣布","纪念","葫芦","象征","老翁"  ,"拜师","悄悄","跪","诚恳","徒弟","属","物质","具体","内向","下降","相反","坚强","外向","上升"  ,"理论","长期","观察","规律","运用","分析","器官","统一","按照","解释","平衡","损害","产生","手段"  ,"黄帝内经","脏腑","三焦","原则","旺盛","引起","全面","分别","次要","关联","处理","发作","淤血"  ,"发汗解表","燥湿化痰","平肝潜阳","泻下","内实证","症候","滋阴","组成","偏旁","缺少","概念","对应"  ,"属性","炎热","概括","明白","起源","制约","循环","神秘","邻居","密码","天文","历法","临床","生理"  ,"病理","诊断","辣","咸","伤害","反映","过度","烦躁","充实","脉象","著名","医学家","文学家"  ,"历史学家","编写","并","立志","广泛","劝","坚持","动摇","降临","折磨","轻生","保全","钻研","吸引"  ,"任职","重复","整理","记载","截取","针灸甲乙经","风痹症","脏象","经络","针法","格言","传统","造福"  ,"失望","叹息","志向","高尚","保持","鼓舞","委婉","擅长"];         arr.sort(function(){//随机打乱这个数组  return Math.random()-0.5;         })         document.write(arr.join(" "));//控制台随机输出打乱后的字符  </script> </head> <body> <from> </from> </body> </html>
查看完整描述

1 回答

已采纳
?
柠檬酸钠

TA贡献331条经验 获得超534个赞

for (var i=0;i<arr.length;i++) {
  document.body.appendChild(arr[i]+'<input type="checkbox">')
}


查看完整回答
2 反对 回复 2016-07-11
  • Einson
    Einson
    我是初学者,我应该怎么加进这段代码进去?我试过怎么什么都显示不出来了
  • 柠檬酸钠
    柠檬酸钠
    打开控制台看一下有没有报错,把document.write用这段代码替换掉
  • 1 回答
  • 0 关注
  • 1267 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信