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 7622257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:24:22+00:00 2026-05-31T04:24:22+00:00

When elements are placed / dropped (by dragging from one DIV to another) and

  • 0

When elements are placed / dropped (by dragging from one DIV to another) and then removing one in the dropped DIV, some of them are changing the position.

Here is a test scenario: http://jsfiddle.net/TcYHW/8/

And the main code:

<div id="dropwin"></div>
<div id="dragables">
    <div id="d1" class="d"></div>
    <div id="d2" class="d"></div>
    <div id="d3" class="d"></div>
    <div id="d4" class="d"></div>
</div>


$(".d").draggable({
        containment: '#dropwin',
        stack: '#dragables div',
        cursor: 'move',
      });

How can I avoid this?

I found, that the elements are placed in relative position to the starting position. How can I make them stick at the dropped position even if some are removed?

I found two near similar questions, but without an satisfying answer:

Remove in Jquery divs with draggables and resizables

jQuery draggable removing without changing position of other elements

  • 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-31T04:24:24+00:00Added an answer on May 31, 2026 at 4:24 am

    You need your elements to be positioned absolute. Then the deleted boxes won’t affect the flow of the other elements.

    You could just use css to position them absolute:

    .d { 
        width: 50px;
        height: 50px;
        margin: 10px;
        display: inline-block;
        position: absolute;
    }
    

    But then you would have to manually place each box. The trick is to leave them positioned static (or relative after .draggable() gets done) and then use javascript to set their positions and set them to absolute positioning:

    $('.d').each(function() {
        var top = $(this).position().top + 'px';
        var left = $(this).position().left + 'px';
        $(this).css({top: top, left: left});
    }).css({position: 'absolute'});
    

    Demo: http://jsfiddle.net/jtbowden/5S92K/

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

Sidebar

Related Questions

I have a lot of UI elements placed inside a canvas. Some of them
I have a set of images placed as position:relative (showing one next to the
I have UIScrollView where placed elements(elements placed from the top to down), how can
Here's my dilemma - I have a two-column list of elements (styled <div> s)
What are some generally accepted practices for navigating between irregularly placed and sized elements
I have a situation where particular elements (xs:simpleType, xs:complexType) are placed in the output
I have read in a lot of places to center elements (a div for
i have several common elements (components), that will generate some html. it seems my
I want to horizontally position some text along with two dropdown menus like: Text
I have a div which contains number of elements which user can drag and

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.