求助 关于在表格里添加一个按钮 我想通过一个按钮在一个表格里添加一行一列 并在该列添加一个新按钮 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <table border="1" id="tb1"></table>function addRow(){ var tbody = document.getElementById('tb1'); var NewRow = tbody.insertRow(0); var NewCell = NewRow.insertCell(0); NewCell.setAttribute("width", "180"); NewCell.setAttribute("align", "left"); NewCell.innerHTML = '<input type="button" id="gg" value="我是按钮"/>';} <!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>test</title> </head> <body> <button id="btn">click</button> <table id="abc" border="1"> <tr><td>内容</td><td>按钮</td></tr> </table> <script type="text/javascript"> window.onload = function(){ document.getElementById("btn").onclick=function(){ var tb = document.getElementById("abc"); var tbody = tb.tBodies[0]; var tr = tbody.insertRow(tbody.rows.length); var td = tr.insertCell(0); td.innerHTML = 'hello'; td = tr.insertCell(1); var btn = document.createElement("button"); btn.innerHTML = "ok"; td.appendChild(btn); } } </script> </body> </html> function addRow(){ var tbody = document.getElementById('tb1'); var NewRow = tbody.insertRow(0); var NewCell = NewRow.insertCell(0); NewCell.setAttribute("width", "180"); NewCell.setAttribute("align", "left"); NewCell.innerHTML = '<input type="button" id="gg" value="我是按钮"/>';} 一行好办,addrow就可以,一列就比较麻烦要循环每一行addcell 怎么用js动态改变圆的半径 jquery 让光标焦点在文本框右边 请帮我加一个实时读取的txt方法吧 JS代码在火孤里没有反应 javascript 变量长度问题 文本框双击后下拉的问题 如何在父窗口读取子窗口的html源文件? 求js 网页全屏代码 分享下使用jquery遇到的怪现象 Array.prototype.slice.call(arguments, 1) 关于在JS中用JSON传递HTML DOM IE8下如何改变其他窗口的属性?
function addRow()
{
var tbody = document.getElementById('tb1');
var NewRow = tbody.insertRow(0);
var NewCell = NewRow.insertCell(0);
NewCell.setAttribute("width", "180");
NewCell.setAttribute("align", "left");
NewCell.innerHTML = '<input type="button" id="gg" value="我是按钮"/>';
}
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
</head>
<body>
<button id="btn">click</button>
<table id="abc" border="1">
<tr><td>内容</td><td>按钮</td></tr>
</table>
<script type="text/javascript">
window.onload = function(){
document.getElementById("btn").onclick=function(){
var tb = document.getElementById("abc");
var tbody = tb.tBodies[0];
var tr = tbody.insertRow(tbody.rows.length);
var td = tr.insertCell(0);
td.innerHTML = 'hello';
td = tr.insertCell(1);
var btn = document.createElement("button");
btn.innerHTML = "ok";
td.appendChild(btn);
}
}
</script>
</body>
</html>
{
var tbody = document.getElementById('tb1');
var NewRow = tbody.insertRow(0);
var NewCell = NewRow.insertCell(0);
NewCell.setAttribute("width", "180");
NewCell.setAttribute("align", "left");
NewCell.innerHTML = '<input type="button" id="gg" value="我是按钮"/>';
}