How to use HTML Detach Method in JQuery

This article describe about HTML Detach Method in JQuery.
  • 1708

HTML detach() method in jQuery

Detach() method is used to remove all element.

But this method keep a copy for the remove element.

When we use insert method after some time then Detach method provide the remove data.

Syntax

$(selector).detach()

Example

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function ()

{

        $("button").click(function ()

{

            $("p").detach();

        });

    });

</script>

</head>

<body>

<p>This is a JQuery.</p>

<p>This is a .Netheaven.</p>

<button>Remove all p elements after click this button</button>

</body>

</html>

Output1

op1.jpg

Output2

op2.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.