HTML and CSS Reference
<link rel="stylesheet" type="text/css" href="styles/tasks.css" media="screen" />
You may notice that it is no longer necessary to specify that the language of
This is all that is required in order to start using the jQuery Template plugin. When the
script loads it will automatically add new features to jQuery, just as our own custom plugin
added new features to jQuery.
When new tasks are created via the form, we need to dynamically add them to the table ;
this means creating a new tr element in the table, and adding the appropriate td columns.
We could achieve this with jQuery directly by generating a string to represent the HTML
and then appending it to the table. As we saw earlier in this chapter, it is possible to gener-
ate elements directly out of HTML and add them into the DOM.
Constructing HTML within code is error prone however, and it would be more convenient
if we can write the basic structure of the row as HTML, and leave placeholders for the dy-
Templating libraries are widely used in software development. Like jQuery tem-
plate, they provide basic control structures such as loops and branching, and al-
low placeholders for parameters.
jQuery template allows us to define the following template in the HTML page:
<script id="taskRow" type="text/x-jQuery-tmpl">