zyadmin
原文为   https://www.cnblogs.com/LuoXiaoTing604404828/p/5124207.html

<
head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>获取checkbox后的文本</title> </head> <script language="javascript"> function getChkValue(){ var obj=document.getElementsByName("intrests"); for(var i=0;i<obj.length;i++){ if(obj[i].checked){ alert(obj[i].value+","+obj[i].nextSibling.nodeValue); } } } </script> <body> <form name="form1" method="post" action=""> <input type="checkbox" name="intrests" value="1">a<br> <input type="checkbox" name="intrests" value="2">b<br> <input type="checkbox" name="intrests" value="3">c<br> <input type="checkbox" name="intrests" value="4">d<br> <input type="checkbox" name="intrests" value="5">e<br> <input type="checkbox" name="intrests" value="6">f<br> <input type="checkbox" name="intrests" value="7">g<br> <input type="checkbox" name="intrests" value="8">h<br><br> <input type="button" onclick="getChkValue()" value="提交"> </form> </body> </html>

 

分类:

技术点:

相关文章:

  • 2021-10-02
  • 2021-12-23
  • 2021-11-07
  • 2022-01-02
  • 2021-10-12
  • 2021-12-28
  • 2022-01-02
  • 2021-10-02
猜你喜欢
  • 2021-10-02
  • 2021-10-02
  • 2021-10-02
  • 2021-10-02
  • 2021-12-16
  • 2021-10-02
  • 2021-10-02
相关资源
相似解决方案