How to use HTML Empty Method in JQuery

This article describe about HTML Empty Method in JQuery.
  • 1631

HTML empty() method in jQuery

The empty method is used to remove all content.

This method remove only selected element.

empty method do not have any value.

This method does not remove the element about it self. 

Syntax

$(selector).empty()

Example

<!DOCTYPE html>

<html>

<head>

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

<script type="text/javascript">

    $(document).ready(function ()

{

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

{

            $("p").empty();

        });

    });

</script>

</head>

<body>

<p style="width:100px;height:100px;background-color:red">This is a JQuery.</p>

<button>Remove content after click this button</button>

</body>

</html>

Output1

op1.jpg

Ouyput2

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

© 2019 DotNetHeaven. All rights reserved.