每一行都一个按钮,点击这个按钮,在此按钮所在的行的下面增加一行?js怎么写哦?
解决方案 »
- IE8下图片排列有问题,万恶的浏览器呀!!
- 贴端代码,请大家分析一下defer
- 关于自己写个类似fckeditor的东西
- javascript:急等!!!
- 文字无法成功链接
- 请问一下,这样为什么会报错啊?没有道理啊
- *********有点难度的问题.高手请进,100分相送*******
- 客户端读取datagrid单元格数据(编辑状态)的问题?
- 在线给分,急急急!!如何从数据库中读取数据,然后显示在两极相关联选择框中的问题!
- 新手求助:有没有实现DOM指定元素删除其中两个数值的软件或脚本
- js中如何把2009年2月28日 12:23转换成2009-02-28 12:23的形式??
- 每分了,请假一个巨难问题
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<META http-equiv="Content-Style-Type" content="text/css">
</head>
<script language=javascript>
var TH_HEIGHT="20px";
var THCOLOR="#ffff99";
var THBGCOLOR= "#ccecff";
var NEW_COLOR="#ffffff";
var rows=0;
function createEventTable() {
var newRow,col1,col2,col3;
var ln = document.getElementById("tb1").rows.length;
if( ln > 0){
for(var i=0; i<ln; i++){
if(document.getElementById("tb1").rows.length <= 0)break;
document.getElementById("tb1").deleteRow(-1);
}
}
for(var colno=0; colno<rows; colno++){
newRow = document.getElementById("tb1").insertRow(-1);
newRow.id = 'r'+colno;
document.getElementById("r"+colno).height = TH_HEIGHT;
document.getElementById("r"+colno).bgColor = THCOLOR;
col1=newRow.insertCell(0);
col2=newRow.insertCell(1);
col3=newRow.insertCell(2);
col1.id="col1"+colno
col2.id = "col2"+colno;
col3.id = "col3"+colno;
col1.innerText = "列一"+colno;
col2.innerText = "列二"+colno;
col3.innerText = "列三"+colno;
col1.onclick=alertMe
col2.onclick=alertMe
col3.onclick=alertMe
}
}
function alertMe(){
alert("我的ID是"+this.id)
}
window.onload=function(){
}
function addline(){
rows++;
createEventTable();
}
</script>
<body >
<div><input type=button onclick=addline() value=" + ">
</div> <TABLE cellSpacing="0" borderColorDark="black" cellPadding="1" borderColorLight="black" border="1" ID="Table1">
<thead>
<COLGROUP>
<COL align="center">
</COL>
<COL align="center">
</COL>
<COL align="center">
</COL>
<COL align="center">
</COL>
<TR height="22px" bgColor="#ccecff">
<TH width="36" >列1</TH>
<TH width="36" >列2</TH>
<TH width="36" >列3</TH>
</TR>
</thead>
<TBODY id="tb1">
</TBODY>
</TABLE></body>
</html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<META http-equiv="Content-Style-Type" content="text/css">
<script language="javascript">
function addInput(){
var div=document.getElementById("inputDiv");
var input=document.createElement("input");
div.appendChild(input);
}
function decInput(){
var div=document.getElementById("inputDiv");
var nodeLen=div.childNodes.length;
if(div.childNodes[nodeLen-1]!=null&&nodeLen>4)
div.removeChild(div.childNodes[nodeLen-1]);
}
window.onload=function(){
}
</script>
</head>
<body>
<div id="inputDiv"><input type="text" /><input type="button" onclick="addInput()" value="+" ></inpit><input type="button" onclick="decInput()" value="-" ></inpit></div>
<div></div>
</body>
</html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<META http-equiv="Content-Style-Type" content="text/css">
<script language="javascript">
function addInput(){
var div=document.getElementById("inputDiv")
var input="<input type=text ><input type=button onclick=addInput() value=\"+\">"
div.innerHTML+=input;
var br=document.createElement("br");
div.appendChild(br);
}
window.onload=function(){
}
</script>
</head>
<body>
<div id="inputDiv"><input type="text" ID="Text1" NAME="Text1"/><input type="button" onclick="addInput()" value="+" ID="Button1" NAME="Button1"></input></br></div>
<div></div>
</body>
</html>
<html>
<head>
<title></title>
<script type="text/javascript">
var i = 1 ;
function add(){
i++ ;
var obj = event.srcElement;
var tr = obj.parentNode.parentNode ;
var tb = document.getElementById("tb") ;
var row = tb.insertRow(tr.rowIndex+1) ;
var cell1 = row.insertCell(0) ;
cell1.innerHTML = i + "" ;
var cell2 = row.insertCell(1) ;
cell2.innerHTML = "<input type='button' value='添加' onclick='add()'>" ;
} </script>
</head>
<body>
<table id="tb" border="1">
<tr>
<td>id</td>
<td>添加</td>
</tr>
<tr>
<td>1</td>
<td><input type="button" value="添加" onclick="add()"></td>
</tr>
</table>
</body>
</html>
function Add_Tr(){
var Tr = document.getElementById("tab").insertRow();
var Td = Tr.insertCell();
Td.innerHTML = "这是新增的一行";
}
</script>
<table id="tab" border="1">
<tr>
<td>这是默认的啊</td>
</tr>
</table>
<input type="button" value="添加一行" onclick="Add_Tr()" />