RawClicked
对于这样的事件,我有 tr 的旧分配方法:
<tr ondblclick="RawClicked(this) .......
我想像这样在 JavaScript 代码中附加事件,并删除在 HTML 标记中分配事件处理程序<tr .... >
:
var element = document.getElementById("CustomersTable").getElementsByTagName("tr");
AssigningEventHandles(element, "dblclick", RawClicked(this));
function AssigningEventHandles(element, event, handler) {
if (element.addEventListener) {
element.addEventListener(event, handler, false);
}
else if (element.attachEvent) {
element.attachEvent("on"+ event, handler);
}
}
function RawClicked(raw) {
var rawDoubleClicked = raw.id;
alert(rawDoubleClicked);
}
this
那么在这种情况下如何将参数传递给函数呢?