Situatie
Metoda jQuery empty() elimină elementele copil ale elementului HTML selectat.
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″).empty();
});
});
</script>
</head>
<body>
<div id=”div1″ style=”height:100px; width:300px; border:1px solid black; background-color:yellow;”>
<a href=”#”>Acesta este un link</a>
<p>Acesta este un paragraf din div.</p>
<p>Acesta este un alt paragraf din div.</p>
</div>
<br>
<button>Golește elementul div</button>
</body>
</html>
Leave A Comment?