2

I have a jquery script that on the occurrence of an event changes a div and adds a table as shown in the following code. The page is based on Bootstrap CSS but the table is not formatted as it should. What am i doing wrong?

$('#regionId').html('<table class="table">');

for (var i = 0; i < data.length; i++) {
$('#regionId').append('<tr><td>'+ data[i].field + ' </td> <td>' + data[i].field2+ '</td></tr>');

}

$('#regionId').append('</table>');
1
  • Please post a fiddle and html markup. Commented May 29, 2014 at 5:49

1 Answer 1

3

try this demo

$('#regionId').html('<table class="table"><tbody></tbody></table>');
    for (var i = 0; i < data.length; i++) {
        $('#regionId tbody').append('<tr><td>'+ data[i].field
                        + ' </td> <td>'
                            + data[i].field2
                            + '</td></tr>')
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.