Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I removed a div and I want to add it back

Tags:

javascript

I removed a div using $(".className").remove() and I want to add it back

I tried the obvious, $(".className").add() but it doesn't get the job done. Any solutions?

like image 294
Alex Dobre Avatar asked Dec 20 '25 19:12

Alex Dobre


1 Answers

If you want to put it back, then you have to store it somewhere. If you just remove it, then you are throwing it away.

let $savedClassName = $(".className");
$savedClassName.remove();

Then to put it back you need to say where you want to put it. e.g.

$("#parent").append($savedClassName);
like image 75
Quentin Avatar answered Dec 23 '25 08:12

Quentin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!