日期:2014-05-16 浏览次数:20313 次
<html><head><title></title></head><body> <input type="hidden" name="xxx" id="xxx" /> <div id="editor" style="border:1px solid #CCCCCC;"> 请输入身份证号码! </div> <a href="#" id="c">清空</a> <a href="#" id="i">生成表格</a> <div id="pp"></div> <script> var edt = document.getElementById('editor'); var edtor = document.getElementById('xxx'); var l=document.getElementById('c'); var p=document.getElementById('i'); var p2=document.getElementById('pp'); p.onclick=function(){ var temp=edtor.value; var temp2=temp.split(" "); var temp3; var tt; var s="<table border='1'>"; for (var te=0;te<temp2.length;te++) {//毛病我应该就在这个中括号内,却怎么也找不出来 :( s+="<tr>"; temp3=temp2[te].value; for(tt=0;tt<temp3.length;tt++) s+="<td>"+temp3[tt].toString(10)+"</td>"; s+="</tr>"; } s+="</table>"; p2.innerHTML=s; } l.onclick=function(){ edt.innerHTML="请输入身份证号码!"; } edt.onclick = function(){ if ((this.childNodes[0].nodeName!='TEXTAREA')||(this.childNodes.length>1)){ var e = document.createElement('textarea'); e.style.width = this.offsetWidth; e.value = edtor.value = this.innerHTML; this.innerHTML = ''; this.appendChild(e); e.focus(); e.onblur = function(){ this.parentNode.innerHTML = edtor.value = this.value; } } } </script> </body> </html>