Sunday, 9 December 2012

jQuery empty() and remove() methods by Example in ASP.NET

ASP.NET:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>jQuery empty() and remove() methods by Example</title>
    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    <style type="text/css">
        .btn
        {
            margin-right: 15px;
            width: 80px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <h4 style="color: Green">
        jQuery empty() and remove() methos example</h4>
    <div id="firstDiv" style="border: 1px solid Red;">
        I am First Div
        <div id="innerDiv">
            I'm a inner Div
        </div>
    </div>
    <div>
        <asp:Button ID="btnEmpty" runat="server" Text="Empty" class="btn"
            CssClass="btn" />
        <asp:Button ID="btnRemove" runat="server" Text="Remove" class="btn" />
        <asp:Button ID="btnReset" runat="server" Text="Reset" class="btn" />
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnReset").click(function () {
                alert("Div content after empty/Remove: " + $("#firstDiv").html());
                location.reload();
                return false;
            });

            $("#btnEmpty").click(function () {
                $('#firstDiv').empty();
                return false;
            });

            $("#btnRemove").click(function () {

                $('#firstDiv').remove();
                return false;
            });
        });
    </script>
    </form>
</body>
</html>



Output:











No comments:

Post a Comment

© 2012-2014 Aspdotnet-Kishore.blogspot.com. All Rights Reserved.
The content is copyrighted to Kishore and may not be reproduced on other websites without permission from the owner.