Situatie
Metoda jQuery remove() elimină elementul HTML selectat și elementele sale copil.
Solutie
Pasi de urmat
<!DOCTYPE html>
<html>
<head>
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js”></script>
<script>
$(document).ready(function(){
$(“button”).click(function(){
$(“#div1″).remove();
});
});
</script>
</head>
<body>
<div id=”div1″ style=”height:100px;width:300px;border:1px solid black;background-color:yellow;”>
Acesta este un text din div.
<p>Acesta este un paragraf din div.</p>
<p>Acesta este un alt paragraf din div.</p>
</div>
<br>
<button>Eliminați elementul div</button>
</body>
</html>
Leave A Comment?