jquery uses templates to dynamically add HTML elements
1, the development of the time to cycle to load the list, usually we use the page <c:foreach> tag loop loading the background data.
<C:foreachItems= "${srmodel.bplbatchplanitem}"var= "Items"Varstatus= "S"> <TR> <TD><inputname= "ItemId"type= "checkbox"value= "${items.id}"Mtype= "${items.materialtype}" ></TD> <TD>${ITEMS.ATTR1}</TD> <TD>${items.materialcode}</TD> <TD>${items.materialtype}</TD> <TD>${items.materialname}</TD> <TD>${items.specification}</TD> <TD>${items.normaldrawing}</TD> <TD>${items.unit}</TD> <Fmt:formatnumberpattern="#.########"value= "${items.bidnumber}"var= "Bidnumber"/> <TD>${bidnumber}</TD> <Fmt:formatnumberpattern="#.########"value= "${items.budgetprice}"var= "Budgetprice"/> <TD>${budgetprice}</TD> <Fmt:formatnumberpattern="#.########"value= "${items.budgetfreightprice}"var= "Budgetfreightprice"/> <TD>${budgetfreightprice}</TD> <Fmt:formatnumberpattern="#.########"value= "${items.budgetinstallprice}"var= "Budgetinstallprice"/> <TD>${budgetinstallprice}</TD> <Fmt:formatnumberpattern="#.########"value= "${items.budgettotalprice}"var= "Budgettotalprice"/> <TD>${budgettotalprice}</TD> <TD>${items.deliveryplace}</TD> <TD>${items.consignee}</TD> <TD>${items.deliverystatus}</TD> <TD>${items.deliveryconditions}</TD> <TD>${items.deliverydate}</TD> <TD>${items.remarks}</TD> </TR> </C:foreach>
But sometimes our data need to use JS to load, you can no longer use <c:foreach>.
Workaround $.format () method.
2, need to add a hidden template in the JSP now.
3. Get the template, and then populate the placeholder. Placeholder will press {0}{1} ... Sequential padding, which can occur multiple times.
var temp=$.format ($ ("#template1"). Val ()); $ ("#tbody1"). Append (Temp ("QW", "N", "Ererer", "RTRT", " 1212121 "," 555555555 ");//Add Element
jquery uses templates to dynamically add HTML elements, equivalent to the foreach in Jstl