首页 > 其他 > 详细

获取checkbox后面的文本内容

时间:2016-01-12 15:32:29      阅读:86      评论:0      收藏:0      [点我收藏+]

http://alygle.blog.51cto.com/1922399/669040

<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> 

 

获取checkbox后面的文本内容

原文:http://www.cnblogs.com/LuoXiaoTing604404828/p/5124207.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!