Imagem de fundo

Observe o código a seguir._<!DOCTYPE html>_<html>__<head>___<scrip...

Observe o código a seguir.


_<!DOCTYPE html>

_<html>

__<head>

___<script

src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">

_</script>

__<script>

____//Inserir código aqui

__</script>

_</head>


<body>

___<h3>Lorem Ipsum</h3>


<div>

_Lorem ipsum dolor sit amet, consectetur adipiscing elit.

_<p>Pellentesque ut nunc elit. Nullam rutrum nibh placerat.</p>

</div>


<p>Fusce rutrum, lacus in laoreet egestas, ex lacus laoreet quam</p>


<p>Vestibulum ante ipsum primis in posuere cubilia curae</p>


__-_<button>Remover</button>

__</body>

</html>


Para adicionar ao botão o comportamento de remover apenas os elementos-filhos e o conteúdo do elemento div, pode-se utilizar o seguinte trecho de código no elemento script:

A

$(document).ready(function(){

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

___$("div").empty();

_});

});

B

$(document).ready(function(){

__$("button").click(

___$("div").clear());

});

C

$(document).ready(function(){

_$("Remover").click(function(){

___$("div").removeContent();

_});

});

D

$(document).ready(function(){

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

___$("div").remove());

});

E

$(document).ready(function(){

_$("Remover").click(

___$("div").empty(“p”));

});