谁能帮我看下这段js代码哪里错了吗?运行不出来
<head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><title>无标题文档</...
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
function inRow()
{
var NewRow=document.getElementById("myTable").insertRow(0);
var row1=NewRow.insertCell(0);
var row2=NewRow.insertCell(1);
row1.innerHTML="新行Cell1";
row2.innerHTML="新行Cell2";
}
</script>
</head>
<body>
<table width="400" border="1" cellspacing="0" cellpadding="0" id="myTable">
<tr id="row1">
<td>Row1 cell1</td>
<td>Row1 cell2</td>
</tr>
<tr>
<td>Row2 cell1</td>
<td>Row2 cell2</td>
</tr>
<tr>
<td>Row3 cell1</td>
<td>Row3 cell2</td>
</tr>
</table>
<input name="newrow" type="button" value="插入新行" inclick="inRow()"/>
</body> 展开
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
function inRow()
{
var NewRow=document.getElementById("myTable").insertRow(0);
var row1=NewRow.insertCell(0);
var row2=NewRow.insertCell(1);
row1.innerHTML="新行Cell1";
row2.innerHTML="新行Cell2";
}
</script>
</head>
<body>
<table width="400" border="1" cellspacing="0" cellpadding="0" id="myTable">
<tr id="row1">
<td>Row1 cell1</td>
<td>Row1 cell2</td>
</tr>
<tr>
<td>Row2 cell1</td>
<td>Row2 cell2</td>
</tr>
<tr>
<td>Row3 cell1</td>
<td>Row3 cell2</td>
</tr>
</table>
<input name="newrow" type="button" value="插入新行" inclick="inRow()"/>
</body> 展开
1个回答
展开全部
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
function inRow()
{
var NewRow=myTable.insertRow(myTable.rows.length);
var Cell1=NewRow.insertCell(NewRow.cells.length);
var Cell2=NewRow.insertCell(NewRow.cells.length);
Cell1.innerHTML="新行Cell1";
Cell2.innerHTML="新行Cell2";
}
</script>
</head>
<body>
<table width="400" border="1" cellspacing="0" cellpadding="0" id="myTable">
<tr id="row1">
<td>Row1 cell1</td>
<td>Row1 cell2</td>
</tr>
<tr>
<td>Row2 cell1</td>
<td>Row2 cell2</td>
</tr>
<tr>
<td>Row3 cell1</td>
<td>Row3 cell2</td>
</tr>
</table>
<input name="newrow" type="button" value="插入新行" onclick="inRow()"/>
</body>
追问
不好意思啊,还是没用诶,能继续帮我解决一下么?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询