tags:

views:

38

answers:

2

Hello,

I have a image gallery inside a <div> which contains 10 photos. How can i delete them using ajax? I want one cross sign to appear at the top right corner of each photo and when user clicks on it, the image should get deleted. And the whole <div> should get refreshed. I do know working with jquery ajax. But is there any plugin available in Jquery that can this visually appealing?

Thanks in advance :)

+3  A: 

jQuery: use the something.remove() method

DOM: use the parent.removeChild(something) method

wybiral
If you actually want the image to stay deleted on reload you'll need to set some sort of flag somewhere. Or have a script elsewhere to delete it from your db, etc.
Daniel Bingham
For what you want visually, just overlay some X button that binds to a click event that calls `.remove` on the image (well, the container holding the image and X button).
wybiral
A: 

If you are actually wanting to delete the image from the server, or from the page so that other viewers will no longer see it, then you will need to have a server URI that deletes the resource. This can be called from JavaScript, but needs a server action.

Matthew Schinckel