要删除某行一定要知道那行的rowIndex;
解决方案 »
- 能修改网页中的运行着的JS代码么?该怎么修改?
- 如何让 div 自由的显示在 框架上?? 急...
- Extjs如何使用GMapPanel在地图上增加标记
- 选 A 吧?
- 如何封装几个方法到一个对象中,然后传值?
- 在javascript里面调用ActiveXObject,它是不是调用的服务端的控件啊?详情请进...
- 请问如何做自动提交页面?
- 请问,怎么让网而一进入就没有工具栏?
- 怎么实现http://sms.sina.com.cn/cgi-bin/sms/ringlist.cgi?aid=31&type=&sort=2里那些下拉菜单呢。
- JavaScript中关于call函数的理解
- 请问this对象可以是当前的标签吗?
- 求一个正则
<script>window.onload=init;
function init(){
var cb = document.getElementById("cb");
cb.TR=document.getElementById("theTR");
cb.onclick=theCheckBoxEvent;
}function theCheckBoxEvent(){
if(this.checked==false){
deleARow(this.TR);
}
}function deleARow(tr){
tr.parentElement.removeChild(tr);
}
</script>
<body>
<table id="tab">
<tr id="theTR" ><td><input type="checkbox" id="cb" checked /></td></tr>
</table>
</body>
</html>
cb.TR=...你创建的时候哪行
<script>
alert()
window.onload=init;
function init(){
window.table=document.getElementById("tab");
window.tbody=document.createElement("tbody");
table.appendChild(tbody);
addARow();
}
function createCheckBox(tr){
var cb = document.createElement("input");
cb.type="checkbox";
cb.onclick= theCheckBoxEvent;
cb.TR=tr;
return cb;
}
function theCheckBoxEvent(){
if(this.checked){
addARow();
}else{
deleARow(this.TR);
}
}
function addARow(){
var tr=document.createElement("tr");
var td1=document.createElement("td");
td1.innerHTML="本行创建时间:"+new Date();
var td2=document.createElement("td");
var cb=createCheckBox(tr);
td2.appendChild(cb);
tr.appendChild(td1);
tr.appendChild(td2);
window.tbody.appendChild(tr);
}
function deleARow(tr){
tr.parentElement.removeChild(tr);
}
</script><body>
<table id="tab">
</table>
</body>
</html>
再问一下,是不是加了window.tbody.appendChild(tr);这句,才能在页面上显示出来?
<head></head>
<script language="javascript">
function process3(a,b){
newTrr = document.createElement("tr");
newTrr.id="d";
newTdd = document.createElement("td");
testTb.appendChild(newTrr);
newTrr.appendChild(newTdd);
newTdd.innerText="ddddd";
}
</script>
<form name="form1">
<input type="button" value="add" onClick="return process3('01','05');">
<table id="testTb">
<tr>
<td><input type="checkbox">iuehdidjd</td>
</tr>
</table>
</form>
</body>
</html>为什么在页面上显示不出“ddddd”呢?
<head></head>
<script language="javascript">
function process3(a,b){
newTrr = document.createElement("tr");
newTrr.id="d";
newTdd = document.createElement("td");
tbody.appendChild(newTrr);
newTrr.appendChild(newTdd);
newTdd.innerText="ddddd";
}
</script>
<form name="form1">
<input type="button" value="add" onClick="return process3('01','05');">
<table id="testTb">
<tbody id="tbody">
<tr>
<td><input type="checkbox">iuehdidjd</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
用insertRow()就不用~~~