an桉删除出现Uncaught ReferenceError: deleteRow is not defined
<!DOCTYPE html>
<html>
<head>
<title> test</title>
<meta http-equiv="Content-Type" content="text/html ;charset=UTF-8"/>
<script type="text/javascript">
window.onload=function(){
Light();
}
function deleteRow(obj){
var tbody=document.getElementById("table").lastChild;
var tr=obj.parentNode.parentNode;
tbody.removeChild(tr);
}
function add(obj){
var tbody=document.getElementById("table").lastChild;
var tr=document.createElement("tr");
var td=document.createElement("td");
td.innerHTML="<input style='text'>";
tr.appendChild(td);
var td=document.createElement("td");
td.innerHTML="<input style='text'>";
tr.appendChild(td);
var td=document.createElement("td");
td.innerHTML="<a href="javascript:;" onclick="deleteRow(this)"></a>"
tr.appendChild(td);
tbody.appendChild(tr);
Light();
}
function Light(){
var tbody=document.getElementById("table").lastChild;
var trs=document.getElementsByName("tr");
for(var i=1;i<trs.length;i++){
trs[i].onmouseover=function(){
this.style.backgroundColor="red";
}
trs[i].onmoseout=function(){
this.style.backgroundColor="#fff";
}
}
}
</script>
</head>
<body>
<table id="table" border="2" width=50%>
<tr>
<td>Namber</td>
<td>Name</td>
<td>Choice</td>
</tr>
<tr>
<td>16</td>
<td>ALex</td>
<td><a href="javascript:;" onclick="deleteRow(this)">Delete</a></td>
</tr>
<tr>
<td>19</td>
<td>Mike</td>
<td><a href="javascript:;"onclick="deleteRow(this)">Delete</a></td>
</tr>
</table>
<input type="button" value=":add" onclick="add(this)">
</body>
</html>