js动态添加了标签,IE兼容模式下onclick事件不启用

2024-11-20 04:41:58
推荐回答(1个)
回答(1):

function add() {
var newobj = document.createElement("input");
var bodyobj = document.getElementsByTagName("body")[0];
newobj.type = "text";
newobj.className = "marsDate";
newobj.readOnly = "readonly";
newobj.onclick = function(){
showMarsFnDate(this);
}
bodyobj.appendChild(newobj);
}