Wednesday, 20 January 2021

jQuery - How to clear (empty) table (remove all TRs)

 

 Watch this example on YouTube


 

 @using (Html.BeginForm("Index", "Home"))
{
    <div>
        <table id="tbl">
            <tr>
                <td>abc</td>
                <td>abc</td>
                <td>abc</td>
            </tr>
            <tr>
                <td>abc</td>
                <td>abc</td>
                <td>abc</td>
            </tr>
        </table>
    </div>
    <input type="button" id="btnSubmit" value="Submit" />
}

@section Scripts{
<script type="text/javascript">
    $(document).ready(function () {
            $("#btnSubmit").click(function () {
                $("#tbl").empty();
            });
        });
</script>
}

No comments:

Post a Comment