Remove Content
remove()

Removes the HTML element

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

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

        $("#device").remove();

                });

});

</script>

</head>

 

<body>

<p id="device" style="background-color:yellow; height:20px;">This is a paragraph.</p>

<button id="button1">Click Here</button>

</body>

</html>

empty()

Removes the content from the HTML element

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

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

        $("#device").empty();

                });

});

</script>

</head>

 

<body>

<p id="device" style="background-color:yellow; height:20px;">This is a paragraph.</p>

<button id="button1">Click Here</button>

</body>

</html>


Previous
Next