日期:2014-05-16 浏览次数:20373 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script type="text/javascript"> function getit(){ var chks=new Array(); var lbls=new Array(); var val=''; chks=document.getElementsByTagName('input'); lbls=document.getElementsByTagName('label'); for(var i=0;i<chks.length;i++){ if(chks[i].type.toString()=='checkbox'){ /*val+=document.getElementById(chks[i].id).innerText; alert(val);*/ for(var j=0;j<lbls.length;j++){ if(lbls[j].getAttributeNode('for').value==chks[i].id){ val+=lbls[j].innerText.toString(); alert(val); } } } } } </script> </head> <body> <input id="464" type="checkbox" name="464" /> <label for="464"> <b>水果 </b> <br /> </label> <input id="465" type="checkbox" name="465" /> <label for="465">苹果 </label> <input type="button" value="Get" onclick="getit();" /> </body> </html>