1. Reference jquery. tmpl. min. js
<Script type = "text/javascript" src = "/js/jquery. tmpl. min. js"> </script>
2. Write template content
<Script id = "titleTemplate" type = "text/x-jquery-tmpl">
<Tr class = 'odd' id = "tr {{= randomid }}">
<Td align = 'center'> </td>
<Td>
<Input type = 'siden' name = 'id' value = '{{= id}'/>
<Input type = 'text' name = 'shbhc 'class = "vesearchbox validate [required, maxSize [10] "id = 'shbhc {= randomid} 'onclick =" $. showShBox ($ (this), {valueField: 'shbh {= randomid} '}) "value =' {{= shmc} '/>
<Input type = 'did' name = 'shbh 'id = "shbh {= randomid}" value =' {{= shbh} '/>
<Font color = "red"> * </font>
</Td>
<Td>
<Select name = "cpbh" style = "100px" class = "searchselect validate [required, maxSize [30]" id = "select {{= randomid}">
<Option value = "" >= all = </option>
<C: forEach items = "$ {cplist}" var = "cp">
<Option value = "$ {cp. cpbh}" >$ {cp. cpmc} </option>
</C: forEach>
</Select>
<Font color = "red"> * </font>
</Td>
<Td> <input name = 'jzgy' class = 'inputtext validate [required, maxSize [500] 'id = 'jzgy 'size = '20' value =' {{= jzgy} '/>
<Font color = "red"> * </font>
</Td>
<Td align = 'center'>
</Td>
</Tr>
</Script>
3. Click to trigger
// Modify and add a row
Function add (){
Var randomid = new Date (). getTime (); // get the current time
// {"Id": "", "shbh": "", "jzgy": "", "cpbh": "", "shmc ":"", "randomid": randomid} indicates the transferred parameter.
// Name the template titleTemplate. The parameter is {"id": "", "shbh": "", "jzgy": "", "cpbh ":"", "shmc": "", "randomid": the template of randomid} is appended to the end of the tb2 tag.
$ ("# TitleTemplate "). tmpl ({"id": "", "shbh": "", "jzgy": "", "cpbh": "", "shmc ":"", "randomid": randomid }). appendTo ("# tb2 ");
}