官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 墨脱县| 安宁市| 南宫市| 东阳市| 鄱阳县| 和林格尔县| 益阳市| 仙游县| 张家口市| 衡水市| 清远市| 宿州市| 澜沧| 新乡市| 大厂| 黄梅县| 赣榆县| 泗水县| 防城港市| 绥芬河市| 治多县| 高邮市| 东明县| 和静县| 嵊泗县| 米易县| 海原县| 康乐县| 和硕县| 河曲县| 乐清市| 襄垣县| 邛崃市| 漳平市| 竹溪县| 正阳县| 大埔县| 东兴市| 南平市| 顺平县| 临汾市|