📜  typescript 操作 html 对象 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:13.327000             🧑  作者: Mango

代码示例1
ts// 1. Select the div element using the id property
const app = document.getElementById("app");

// 2. Create a new 

element programmatically const p = document.createElement("p"); // 3. Add the text content p.textContent = "Hello, World!"; // 4. Append the p element to the div element app?.appendChild(p);