- HTML5 Web Application Development By Example Beginner's Guide
- J.M. Gustafson
- 124字
- 2021-08-13 16:50:20
HTML templates
As you can see, things are getting a little messy in our addTaskElement()
method. We are creating a bunch of elements programmatically in JavaScript and manually adding them to the DOM. Wouldn't it be a lot easier if we could just define what we want the task element's structure to look like in our HTML file and use it to create new tasks? Well we can, and we will. In this section we'll create an HTML template that we can reuse to easily create new tasks.
Note
There are plenty of JavaScript libraries out there for implementing HTML templates and they have a lot of powerful features, but for our application all we need is something simple, so we'll implement our own.
推薦閱讀
- Java FX應用開發教程
- Python進階編程:編寫更高效、優雅的Python代碼
- TypeScript圖形渲染實戰:基于WebGL的3D架構與實現
- 可解釋機器學習:模型、方法與實踐
- 計算機應用基礎實踐教程
- Visual Basic程序設計上機實驗教程
- Java SE實踐教程
- Node.js開發指南
- PHP編程基礎與實踐教程
- Backbone.js Testing
- Python程序設計教程
- Web前端測試與集成:Jasmine/Selenium/Protractor/Jenkins的最佳實踐
- PHP典型模塊與項目實戰大全
- Scratch超人漫游記:創意程序設計:STEAM創新教育指南
- Spring Microservices