📜  html 字符串中的 javascript 变量 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:54.939000             🧑  作者: Mango

代码示例1
let div = document.createElement("div");
div.classList.add("yourClass");
div.setAttribute("onclick", "yourFunction()");
div.setAttribute("onmouseover", "hoverOn()")
div.style.background = "yourColor";
let divInDiv = document.createElement("div");
divInDiv.classList.add("yourClass");
div.appendChild(divInDiv);