Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - how to undo prepend

I am using the prepend() function to diplay an image when a div is hoevered over. How do I remove the image - i.e. what is the opposite of prepend()

Here is the code:

$("#hover-div").hover(
        function() { $("#image-div").prepend("<img src='images/arrow_redo.png' width='16' height='16' />"); },
        function() { $("#image-div").someFunction("<img src='images/arrow_redo.png' width='16' height='16' />"); }
        );

someFunction is just a dummy - I am not really expecting it to do anything.

like image 979
Ankur Avatar asked Dec 29 '22 17:12

Ankur


1 Answers

If you have the id for the image element you can simply use the remove method.

$("#imgID").remove();
like image 200
rahul Avatar answered Jan 13 '23 18:01

rahul