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

  • SEARCH
  • Home
  • 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 6800287
In Process

The Archive Base Latest Questions

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

I am implementing drag and drop, user can drag few images and drop them

  • 0

I am implementing drag and drop, user can drag few images and drop them in a div, and I dynamically append a p tag as label to each image once user click on a button.

Currently I meet problem when I have 2 images which is very close to each other (one is on top of another). The appended p tag for the top images will be hidden by the bottom image. I tried to alert the z-index for each dropped image, and found out it is ‘auto’. I guess I need to assign a new z-index for each div, but I tried in the function which i append the label, and it dint work as expect:

 function generateLabel() {
      var current = 5000;
      $('#rightframe img').each(function () {
        var cImgName = $(this).attr('id');
        var width = $(this).width();

        // To select the respective div
        var temp = "div#" + cImgName;
        $.ajax({
            url: '/kitchen/generatelabel',
            type: 'GET',
            data: { containerImgName: cImgName },
            async: false,
            success: function (result) {
                $(temp).append(result);
                // I guess the each function loop through each div according to the time it is created, so I try to assign a decreasing z-index 
                $(temp).css('z-index', current);
                current -= 100;
                // To select the label for the image
                temp += " p";
                // Set label width based on image width
                $(temp).width(width);
            }
        });
    });

However, what I get is, bottom image which dropped later do NOT hide the label of the image above, but if the above image is dropped after than the bottom image, above image’s label is hide by the bottom image.

It’s a very specific situation and I hope I do make myself clear…

Hope can get some help here… Appreciate any feedback…

  • 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-26T18:57:04+00:00Added an answer on May 26, 2026 at 6:57 pm

    I am so glad that I able to work out a solution for this kinda weird problem. I get to one useful plugin, the jquery-overlaps which check 2 dom whether they are overlapped with each other or not. Then i assign a z-index to the label accordingly.

    Just to show my solution here, in case anyone jump into this bottleneck 🙂

     // To assign an increasing z-index to the label
            var count = 100;
            $('#rightdiv p').each(function () {
                // If any label overlaps with the image (used overlaps plugin)
                if ($(this).overlaps($('#rightdiv img'))) {
                    // Increase count (the z-index)
                    count += 10;
                    // Set the parent div z-index 1st, if not the label z-index do not have effect
                    $(this).parent().css('z-index', count);
                    $(this).css('z-index', count);
                }
    
            });
    

    Thanks! 😀

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am implementing an application which can be drag and drop images in a
I'm implementing drag & drop from a ListBox, but I'm seeing some strange behaviour
I'm implementing a drag & drop script in (plain) JavaScript. All good, except one
Windows Phone 7.5 Silverlight app I want to let the user drag the image
I have a Silverlight (v3) application that users can drag controls (e.g. Shapes, Images)
I'm implementing drag & drop on a ListView. I already managed to get the
I'm implementing simple drag-and-drop functionality in my app, and I would like to know
I'm in the midst of implementing drag/drop functionality on a table. How it works:
I'm implementing drag and drop QTreeView based on my custom model. All works fine,
I'm implementing a drag and drop interface with Qt across X11 and Windows .

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.