以下不适用于Firefox.我正在尝试删除点击表格行.谁能请帮忙.非常感谢.
<INPUT TYPE="Button" onClick="delRow()" VALUE="Remove">
function delRow(){
if(window.event){
var current = window.event.srcElement;
}else{
var current = window.event.target;
}
//here we will delete the line
while ( (current = current.parentElement) && current.tagName !="TR");
current.parentElement.removeChild(current);
}
Run Code Online (Sandbox Code Playgroud)
function() { delRow(); }.如您所见event,delRow()除非您在IE中,因为事件在窗口对象中,否则您将无法看到该对象.我建议你使用jQuery这样的javascript库,或者如果你需要保持相对相同的东西就改变你的代码.
<INPUT TYPE="Button" onclick="delRow(event);" VALUE="Remove">
function delRow(e) {
var evt = e || window.event; // this assign evt with the event object
var current = evt.target || evt.srcElement; // this assign current with the event target
// do what you need to do here
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14289 次 |
| 最近记录: |