<html>
<head>
<script type="text/javascript">
function removeLink(i)
{
document.getElementById("tab2").deleteRow(i);
}
</script>
</head>
<body>
<form action="forth.php" method="post">
<table width="600" border="1" id="tab2">
<?php
foreach($_POST as $key => $post2)
{
?>
<tr>
<td>
<?php
echo $post2.'<br />';
?>
<input type="hidden" name="<?php echo $key;?>" value="<?php echo $post2;?>" />
</td>
<td><a href="#" onClick="removeLink(this.parentNode.parentNode.rowIndex);">Remove</a></td>
</tr>
<?php
}
?>
<tr>
<td><input type="submit" value="Next" /></td>
<td> </td>
</tr>
</table>
</form>
</body>
家伙,你可以看到我的锚标记具有onclick函数removeLink(),但它并没有按预期删除整个tr。当点击锚点生成的链接时,它不执行任何操作。有没有像锚不支持内部对象定义在removeLink(this.parentNode.parentNode.rowIndex)的问题?家伙们如何帮助我们做到这一点删除锚不工作
检查Firebug或任何其他错误跟踪工具的JavaScript错误。并让我们知道。 –
你应该使用jquery – botbot
我只需要使用js –