Henry
0
Q:

jquery add a new html element based on a template with variables

<script id="hidden-template" type="text/x-custom-template">
    <tr>
        <td>Foo</td>
        <td>Bar</td>
    <tr>
</script>

then in javascript:

var template = $('#hidden-template').html();
// the following line is to set some value in the template
// if the template code is static you can skip the following line 
template.find('#en-element-to-set-its-value').html("<p>This is the new value</p>");
$('button.addRow').click(function() {
    $('#targetTable').append(template);
});

0

New to Communities?

Join the community