不能添加功能元素javascript
无法添加“点击”功能的JavaScript
功能modalbg.onclick
不行div元素。
var modalbg = document.createElement("div");
document.body.appendChild(modalbg); // to place at end of document
modalbg.onclick(function() {
alert();
})
错误是:
(index):625 Uncaught TypeError: modalbg.onclick is not a function(…)
感谢大卫,这是语法问题。 谢谢:) – Radian