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?
What code is required to delete an image from website?
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;
});
Â
What code is required to delete an image from website?
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