zoukankan      html  css  js  c++  java
  • js获取checkbox中所有选中值及input后面所跟的文本 .

    转自;https://www.cnblogs.com/zhenmingliu/archive/2012/05/15/2502270.html
    1
    <html> 2 <head> 3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 4 <title>js</title> 5 </head> 6 <script language="javascript"> 7 function aa(){ 8 var r=document.getElementsByName("r"); 9 for(var i=0;i<r.length;i++){ 10 if(r[i].checked){ 11 alert(r[i].value+","+r[i].nextSibling.nodeValue); 12 } 13 } 14 } 15 </script> 16 <body> 17 <form name="form1" method="post" action=""> 18 <input type="checkbox" name="r" value="1">a<br> 19 <input type="checkbox" name="r" value="2">b<br> 20 <input type="checkbox" name="r" value="3">c<br> 21 <input type="checkbox" name="r" value="4">d<br> 22 <input type="checkbox" name="r" value="5">e<br> 23 <input type="checkbox" name="r" value="6">f<br> 24 <input type="checkbox" name="r" value="7">g<br> 25 <input type="checkbox" name="r" value="8">h<br> 26 <input type="checkbox" name="r" value="9">i<br> 27 <input type="checkbox" name="r" value="10">j<br> 28 <br> 29 <input type="button" onclick="aa()" value="button"> 30 </form> 31 </body> 32 </html> 33 34 35 36 37 38 39 40 解释: 41 42 nextSibling是获得当前对象的下一个对象 43 nodeValue是返回一个节点的值
  • 相关阅读:
    Python制作回合制手游外挂简单教程(中)
    软件工程知识大纲
    Android应用程序开发
    Python制作回合制手游外挂简单教程(上)
    操作系统概念大纲
    Java三种工厂模式
    Java泛型的理解
    Java动态代理的理解
    编译原理与技术大纲
    新服务器sudo与权限分配<NIOT>
  • 原文地址:https://www.cnblogs.com/sharpest/p/5990408.html
Copyright © 2011-2022 走看看