如何在一个table里的某一指定cell增加一个input? <input name="button" type="button" onclick="document.getElementById('tableId').childNodes[0].childNodes[i].childNodes[j].insertAdjacentHTML('beforeEnd','<input>')"> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <table id="table1" border="1"><tr><td>asd</td><td>asd</td></tr><tr><td>asd</td><td>asd</td></tr></table><input name="button" type="button" onclick="document.getElementById('table1').childNodes[0].childNodes[0].childNodes[0].insertAdjacentHTML('beforeEnd','<input>')"> http://blog.csdn.net/xuStanly/archive/2006/12/09/1436681.aspx供参考。 <html><head><script type="text/javascript">function addInput() { var td = document.getElementById("t").getElementsByTagName("td")[0]; td.appendChild(document.createElement("input"));}</script></head><body><table id="t" border="1"> <tr> <td>asd</td> <td>asd</td> </tr> <tr> <td>asd</td> <td>asd</td> </tr></table><input name="button" type="button" onclick="addInput();"></body></html> 忽忽。这个支持FF。。^o^ 那如何改变一个cell里的input的值呢? 就是说判断是否有这个input,没有就加上,有就改变它的值 <html><head><script type="text/javascript">function addInput() { var input; var td = document.getElementById("t").getElementsByTagName("td")[0]; var input = td.getElementsByTagName("input")[0]; if (!input) { input = document.createElement("input"); input.setAttribute("value", 1); td.appendChild(input); } else { input.value = parseFloat(input.value) + 1; }}</script></head><body><table id="t" border="1"> <tr> <td>asd</td> <td>asd</td> </tr> <tr> <td>asd</td> <td>asd</td> </tr></table><input name="button" type="button" onclick="addInput();"></body></html> 帮忙看看CSS Sprites哪里写错了 [求助]这段代码有什么错误? 如何利用javascript获取URL中的请求参数值?(在线等待,焦急中) 数组相加获得运算结果 div和table隐藏问题? 请教如何通过CGI函数象web server传递参数?? 好无聊的生日~再散200分。 **关于window.location的问题** Ext4.2 store解析json老是有问题 建立飞船打陨石类游戏的框架:包括html代码和陨石的js框架 如何作object里元素的遍历 JS中引号的区别
<tr>
<td>asd
</td>
<td>asd
</td>
</tr>
<tr>
<td>asd
</td>
<td>asd
</td>
</tr>
</table>
<input name="button" type="button" onclick="document.getElementById('table1').childNodes[0].childNodes[0].childNodes[0].insertAdjacentHTML('beforeEnd','<input>')">
<head>
<script type="text/javascript">
function addInput() {
var td = document.getElementById("t").getElementsByTagName("td")[0];
td.appendChild(document.createElement("input"));
}
</script>
</head>
<body>
<table id="t" border="1">
<tr>
<td>asd</td>
<td>asd</td>
</tr>
<tr>
<td>asd</td>
<td>asd</td>
</tr>
</table>
<input name="button" type="button" onclick="addInput();">
</body>
</html>
^o^
<head>
<script type="text/javascript">
function addInput() {
var input;
var td = document.getElementById("t").getElementsByTagName("td")[0];
var input = td.getElementsByTagName("input")[0];
if (!input) {
input = document.createElement("input");
input.setAttribute("value", 1);
td.appendChild(input);
} else {
input.value = parseFloat(input.value) + 1;
}
}
</script>
</head>
<body>
<table id="t" border="1">
<tr>
<td>asd</td>
<td>asd</td>
</tr>
<tr>
<td>asd</td>
<td>asd</td>
</tr>
</table>
<input name="button" type="button" onclick="addInput();">
</body>
</html>