Skip to content

JS CheetSheet

JS参考:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript

JavaScript 动态生成 html

参考链接:使用 JavaScript 怎么动态生成 html? - 两粒疯的回答 - 知乎

使用模板字符串 ${ } ,引号用 `

js
const container = document.querySelector('#container'); 
const title = '动态生成的标题'; 
const html = `<h1>${title}</h1>`; 
container.innerHTML = html;