What code is required to delete an image from website?

Asked By 10 points N/A Posted on -
qa-featured

Hi Experts,

I have created a website which also contains images.

I want to create a small cross on top of every image.

When someone clicks the image, it would be deleted from the list.

But I don’t know the coding to be used for this purpose.

Is it possible to do so if yes, can anyone write the code for Ajax Delete Image?

SHARE
Best Answer by Langford Mikee
Best Answer
Best Answer
Answered By 0 points N/A #160381

What code is required to delete an image from website?

qa-featured

Please try this syntax. 
 
​This will allow the image to disappear by clicking on the image. 
 
 
$("img.delete").click(function() {
var id     = $('#id').attr('value');        
    $.ajax({
        type: "POST",
        url: "delete.php",
        data: "id="+ id,
        success: function(){
            $('tr.selector').remove();
            $('div.success').fadeIn();
        }
    });
return false;
});
 
Answered By 0 points N/A #160382

What code is required to delete an image from website?

qa-featured

Hello Janneya,

I’ll l give you a suggestion that you can make the image disappear instead of deleting the image. Here you can use Visibility:hidden property in CSS.

 
The original CSS applied to the image is show below.
 
            img#mypic {float:right; margin-left:2em}
 
CSS techniques to hide the image:
           img#mypic{float:right; margin-left:2em;visibility:hidden}
 
I guess your web site is a static web site and think this way is suitable for you.
 
Thank you.
 
Rubi Sharlene

Related Questions