remove()
methodYou can simply use the jQuery remove()
method to remove the elements from DOM. This method will remove the matched elements as well as everything inside of it.
The following example will show you how to remove a paragraph from DOM completely.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Remove Elements from DOM</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").remove();
});
});
</script>
</head>
<body>
<button>Remove paragraph</button>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on harsukh21@gmail.com
Most Powerful JavaScript Libraries Designed for Deep Leaning Devlopment
JavaScript, one of the core programming...Counts how many times a substring occurs in a string in PHP
Use the PHP substr_count() fun...How to Delete an Element from an Array in PHP
Use the PHP unset() Function If you w...How to remove white space from the beginning of a string in PHP
Use the PHP ltrim() function...How to add attributes to an HTML element in jQuery
Use the jQuery attr() method You can...