<divclass="div-1"> <p>Lorem ipsum dolor sit amet conse</p> </div> <divclass="div-2"> <p>Lorem ipsum dolor sit amet conse</p> </div> <divclass="div-3"> <p>Lorem ipsum dolor sit amet conse</p> </div>
1 2 3 4 5 6
const returnValue1 = $('.div-1').empty() const returnValue2 = $('.div-2').remove() const returnValue3 = $('.div-3').detach() console.log(returnValue1[0].innerHTML) // '' console.log(returnValue2[0].innerHTML) // <p>Lorem ipsum dolor sit amet conse</p> console.log(returnValue3[0].innerHTML) // <p>Lorem ipsum dolor sit amet conse</p>
<divclass="div-1"> <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit</p> </div> <divclass="div-2"> <p>Lorem ipsum dolor sit amet conse</p> </div> <divclass="div-3"> <p>Lorem ipsum dolor sit</p> </div>