<!DOCTYPE html><html> <head> <title> new document </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <script type="text/javascript"> // 創(chuàng)建刪除函數(shù) function jian(row){ var node=document.getElementById("table"); node.deleteRow(row); } </script> </head> <body> <table border="1" width="50%" id="table"> <tr> <th>學(xué)號</th> <th>姓名</th> <th>操作</th> </tr> <tr> <td>xh001</td> <td>王小明</td> <td><a href="javascript:;" onclick="jian(this)">刪除</a></td> <!--在刪除按鈕上添加點擊事件 --> </tr> <tr> <td>xh002</td> <td>劉小芳</td> <td><a href="javascript:;" onclick="jian(this)">刪除</a></td> <!--在刪除按鈕上添加點擊事件 --> </tr> </table> </body></html>為什么this被當(dāng)成了0來執(zhí)行,而不是報編譯錯誤,求指教啊求指教?。?
執(zhí)行table的deleteRow方法,為什么當(dāng)<a>對象作為參數(shù)的,被默認(rèn)為了0
拉風(fēng)的咖菲貓
2018-10-16 13:15:06