我在這裏創造的onclick函數內部的onclick現在的工作內部的onclick功能不能正常工作
element.onclick = function(e) {
var div = document.getElementById("message");
var div1= document.getElementById("send");
var input = document.createElement("textarea");
var button = document.createElement("input");
button.setAttribute("type", "submit");
button.setAttribute("value", "send");
button.setAttribute("id", candidateId);
input.name = "post";
input.maxLength = "500";
input.cols = "30";
input.rows = "10";
div.appendChild(input); //appendChild
div.appendChild(button);
console.log(button)
button.onclick = function(e) {
alert("comming")
}
}
這裏button.onclick功能不開火,任何一個可以幫助我..
https://jsfiddle.net/arunpjohny/g1d26gfL/1/ - >工作正常 –
是否需要自動觸發'button.onclick'?手動點擊發送按鈕時,代碼工作正常。 – Munawir
不工作,我在Java腳本中也動態創建元素。 – arjun