var tr = tab.insertRow(tab.rows.length - 1);//插入到末二行,最后一行要给全选那一行保留着 var td1 = tr.insertCell(-1); td1.innerHTML = "<input type='checkbox'/>"; var td2 = tr.insertCell(-1); td2.innerHTML = mailArr[rowindex].title; var td3 = tr.insertCell(-1); td3.innerHTML = mailArr[rowindex].name; var td4 = tr.insertCell(-1); td4.innerHTML = mailArr[rowindex].date; } } //要使全选按钮生效,就要遍历所有的表格的行
function seleAll(mailTab, isSel) { for (var i = 0; i < mailTab.rows.length; i++) { var tr = mailTab.rows[i]; tr.cells[0].childNodes[0].checked = isSel; } } </script>