我在html中动态添加一个按钮,如下所示:点击该按钮,我想调用一个Javascript函数:
var but = document.createElement("button");
but.value="delete row";
but.setAttribute("onclick","callJavascriptFunction()");
//this is not working
but.onclick="callJavascriptFunction()"
//this is also not working
document.getElementById("but").onclick="callJavascriptFunction()"
//this is also not working
but.id="but"+inc;
Run Code Online (Sandbox Code Playgroud)
有没有办法解决这个问题?Plz帮助我.,提前谢谢