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

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.

主站蜘蛛池模板: 阳江市| 成安县| 惠水县| 珲春市| 南宁市| 宁陕县| 眉山市| 万盛区| 奈曼旗| 昌平区| 镇沅| 钦州市| 黄山市| 抚松县| 泰兴市| 武胜县| 唐海县| 巩义市| 天峻县| 甘泉县| 泰安市| 苍梧县| 建瓯市| 睢宁县| 禄丰县| 曲水县| 岑溪市| 田东县| 桑日县| 姜堰市| 西安市| 玛多县| 永平县| 武强县| 庆元县| 罗田县| 哈巴河县| 扶余县| 介休市| 洛浦县| 海林市|