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

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.

主站蜘蛛池模板: 芦山县| 秦安县| 彰化县| 凤冈县| 景德镇市| 德保县| 西和县| 正镶白旗| 梁山县| 荣成市| 东乌珠穆沁旗| 凤山市| 大荔县| 尼玛县| 绥江县| 平昌县| 綦江县| 寿光市| 扬中市| 进贤县| 宁强县| 会理县| 宜阳县| 乌拉特前旗| 保定市| 成都市| 马边| 益阳市| 七台河市| 榆社县| 新宁县| 长春市| 彭州市| 渭源县| 莲花县| 南昌市| 万源市| 堆龙德庆县| 嘉定区| 成武县| 荥经县|