jQuery addClass example
Change class name on click in jQuery
by atach
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.1.2/handlebars.min.js"></script>
<ul id="invoiceList"></ul>
<script id="templateInvoice" type="x-handlebars-template">
{{#each invoices}}
<li>{{ var2 }}</li>
{{/each}}
</script>
JavaScript
var dataTest = {
total: 4,
invoices: [
{
id: 1,
var1: 354,
var2: 'Test1',
}, {
id: 2,
var1: 300,
var2: 'Test2',
}, {
id: 3,
var1: 124,
var2: 'Test3',
}, {
id: 4,
var1: 354,
var2: 'Test4',
},
]
};
var template = Handlebars.compile($('#templateInvoice').html());
$('#invoiceList').html(template(dataTest));