Saturday 24 November 2018

MVC - jQuery - Create Table Dynamically


Watch this example on YouTube




<div id="TestTable"></div>
@section Scripts{
    <script type="text/javascript">
        $(document).ready(function () {
            $('#TestTable').append("<table>");
            $('#TestTable').append("<tr><th>Col 1</th><th>Col 2</th></tr>");

            for (i = 0; i < 10; i++) {
                $('#TestTable').append('<tr><td> Field ' + i + '</td><td> Field ' + i + '</td></tr>');
            }
            $('#TestTable').append("</table>");
        });
    </script>
    }

No comments:

Post a Comment