📌  相关文章
📜  js 创建具有属性的元素 - Javascript 代码示例

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

代码示例5
/* Oh Sorry, in the previous answer is posted by me but in line 2, I've a problem, see this fixed: */
const element = document.createElement("h1"); /* First need to make element to edit it! */
element.setAttribute("style", /* This */ "text-align:center"); /* Here have a problem, I haven't included " in here*/
document.body.appendChild(element); /* Used to show the element in body tag cuz other tags doesn't have display, see it in DevTools! */