读书人

DOM 对报表的操作 兼容 火狐和IE

发布时间: 2012-10-06 17:34:01 作者: rapoo

DOM 对表格的操作 兼容 火狐和IE

//valueTable 中插入列 function addRow()        {        //设置列内容和属性var newTr = valueTable.insertRow(-1);//添加两列var newTd0 = newTr.insertCell(-1);var newTd1 = newTr.insertCell(-1);var newTd2 = newTr.insertCell(-1);newTd0.align='center'; newTd0.innerHTML = "<input name='userInputName' onChange='checkDot(this);' maxlength='32' type='text' />"; newTd1.align='center'; newTd1.innerHTML="<input name='detectName' onChange='checkDot(this);' maxlength='32' type='text' />";newTd2.align='center'; newTd2.innerHTML="<a  class='edit' href=\"#\" onclick=\"DelTR(this);\">删除</a>";        }//删除 该列function DelTR(obj){if(confirm("是否将表单此属性删除?")){var seq=obj.parentNode.parentNode.rowIndex;var oTab = valueTable;var trLen = oTab.rows.length;    oTab.deleteRow(seq);}}

<table id="valueTable" cellspacing="1"cellpadding="0"><thead><th  width="50%">项目名称</th><th  width="25%">值</th><th > 操作</th></thead><tbody></tbody></table>

读书人网 >Web前端

热点推荐