Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6809263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:03:55+00:00 2026-05-26T20:03:55+00:00

I am trying to upload some images and display them inside an empty DIV

  • 0

I am trying to upload some images and display them inside an empty DIV and after uploading if I mouse hover on an image I should get a delete icon so that users should be able to delete it with an animation and move the next image to the deleted image position.

How do I achieve that?

This is how I am uploading and appending to the div container:

<script type="text/javascript">
 $(function () {
     document.getElementById('Nextbutton').style.visibility = "hidden"; // show 
     $("#uploader").plupload({
         // General settings
         runtimes: 'gears,flash,silverlight,browserplus,html5',
         url: 'Test.aspx',
         max_file_size: '10mb',
         max_file_count: 20,
         chunk_size: '1mb',
         unique_names: true,

         filters: [
            { title: "Image files", extensions: "jpg,gif,png" },
            { title: "Zip files", extensions: "zip" }
        ],


         flash_swf_url: 'js/plupload.flash.swf',


         silverlight_xap_url: 'js/plupload.silverlight.xap'
     });



     $('form').submit(function (e) {
         var uploader = $('#uploader').plupload('getUploader');

         if (uploader.files.length > 0) {

             uploader.bind('StateChanged', function () {
                 if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
                     $('form')[0].submit();
                 }
             });

             uploader.start();

         }
         else
         //alert('You must at least upload one file.');

             return false;
     });
     var uploader = $('#uploader').plupload('getUploader');

     uploader.bind('FilesAdded', function (up, files) {
         //              jQuery('#container a').html('');
         $('#container > *').remove();
         var i = 0;
         while (i++ < up.files.length) {
             var ii = i;
             while (ii < up.files.length) {
                 if (up.files[i - 1].name == up.files[ii].name) {
                     $.msgBox({
                         title: "Ooops",
                         content: "There is already an image with the same filename and cannot be added.",
                         type: "error",
                         showButtons: true,
                         opacity: 0.9,
                         autoClose: false
                     });
                     uploader.removeFile(up.files[ii]);
                 } else {
                     ii++;
                 }
             }
         }
         if (i > 20) {
             $.msgBox({
                 title: "Info",
                 content: "Uuh! Please don't put me any more files.<br>Maximum Upload limit is only 20 Images.<br>Rest of the Images will be removed.",
                 type: "info",
                 showButtons: true,
                 opacity: 0.9,
                 autoClose: false
             });
             $('#uploader_browse').hide();
         }
     });
     uploader.bind('FilesRemoved', function (up, files) {
         if (up.files.length < 20) {
             $('#uploader_browse').fadeIn("slow");
         }
     });


     uploader.bind('FileUploaded', function (up, file, res) {
         $('#container').append("<div class='container a'><a href='uploads/" + document.getElementById("currentDirectory").value + "/" + file.name + "'  rel='prettyPhoto' target='blank'><img src='uploads/" + document.getElementById("currentDirectory").value + "/" + file.name + "' width='64' height='64'/></a></div>");



         var $imageContainers = $('#container a');

         $imageContainers.each(function (index) {
             $(this).delay(index * 50).fadeTo(400, 0.5);
         });

         $imageContainers.mouseover(function () {
             $(this).css('opacity', 1);
             $(this).find('span.del').show();
         });
         $imageContainers.mouseout(function () {
             $(this).css('opacity', 0.5);
             $(this).find('span.del').hide();
         });



         if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
             document.getElementById('Nextbutton').style.visibility = "visible"; // show 
             showStickySuccessToast();
         }
         uploader.removeFile(file);
     });

 });


     function randomString(length) {
         var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('');

         if (!length) {
             length = Math.floor(Math.random() * chars.length);
         }

         var str = '';
         for (var i = 0; i < length; i++) {
             str += chars[Math.floor(Math.random() * chars.length)];
         }
         return str;
     }

    </script>

Here is my div where I am showing the Images:

<div id="container">
</div>   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:03:56+00:00Added an answer on May 26, 2026 at 8:03 pm

    A demo is available at: http://jsfiddle.net/CWaHL/1/

    HTML

    <div id="container">
      <div class="image" id="image1" style="background-image:url(http://lorempixel.com/100/100/abstract);">
        <a href="#" class="delete">Delete</a>
      </div>
      <div class="image" id="image2" style="background-image:url(http://lorempixel.com/100/100/food);">
        <a href="#" class="delete">Delete</a>
      </div>
      <div class="image" id="image3" style="background-image:url(http://lorempixel.com/100/100/people);">
        <a href="#" class="delete">Delete</a>
      </div>
      <div class="image" id="image4" style="background-image:url(http://lorempixel.com/100/100/technics);">
        <a href="#" class="delete">Delete</a>
      </div>
    </div>
    

    CSS

    #container { overflow:auto; }
    .image { width:100px;height:100px;float:left;position:relative; }
    a.delete { display:none;position:absolute;top:0;right:0;width:30px;height:30px;text-indent:-999px;background:red; }
    .image:hover a.delete { display:block; }
    

    jQuery/Javascript

    $(document).ready(function(){
    
      $('a.delete').on('click',function(e){
        e.preventDefault();
        imageID = $(this).closest('.image')[0].id;
        alert('Now deleting "'+imageID+'"');
        $(this).closest('.image')
          .fadeTo(300,0,function(){
            $(this)
              .animate({width:0},200,function(){
                $(this)
                  .remove();
              });
          });
      });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Helllo I am trying to upload some images to the server. If i placed
I am having error after error trying to upload and resize images to s3
I'm using Codeigniter 2. I'm trying to display some images using the background url
I'm trying to upload some videos using PHP. But I can't get them into
I am uploading some images using plupload and adding those images to div container.And
i'm trying to upload some data from an ActiveX control to a webpage. The
I'm trying to write some PHP to upload a file to a folder on
I'm trying to choose some files to upload in Windows Phone 7 (in the
I'm trying to upload an image to my site through a form, however it's
I'm trying to upload some records to my local data store using appcfg.py Only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.