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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:32:11+00:00 2026-05-15T21:32:11+00:00

Say I have Div1 and Div2. I want to make that when a user

  • 0

Say I have Div1 and Div2. I want to make that when a user is dragging around Div1, Div2 should also drag along. Any ideas how do I make it?

Here’s what I got so far…

$(document).ready(function() {
    $("#apDiv1").draggable();
    $("#apDiv2").draggable(); //<- how do I link it do Div1 ?
});

EDIT ——————————————————————

Thanks, I looked into the docs and got so far:

  <script>
$(document).ready(function() {
    $("#apDiv1").draggable();
  });

$( "#apDiv1" ).bind( "drag", function(event, ui) {
                $( "#apDiv2" ).css({ top: event.offsetY, left: event.offsetX });

  </script>

Seems to be right, but… hmm, isn’t’ working. any ideas?

  • 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-15T21:32:12+00:00Added an answer on May 15, 2026 at 9:32 pm

    Regarding your edit I’ve made some changes that can be viewed here http://jsfiddle.net/9FrXr/2/

    You weren’t closing the “drag” bind and instead of event.offsetY and event.offsetX I’ve used ui.offset.top and ui.offset.x. The drag bind has also been moved into the document.ready function.

    $("#apDiv1").bind( "drag", function(event, ui) {
        div.css({ top: ui.offset.top + 52, left: ui.offset.left });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have 2 DIVs: ​<div class="div1"></div> <div class="div2"></div>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ I want to rotate
Say have a linear model LM that I want a qq plot of the
I have a master page with three DIV blocks, say div1, div2, div3. I
I have two divs. Say div1 and div2. By default div2 is invisible. When
let's say that i have something like this: <head><script src=script1.js ...></script></head> <body><div id=div1></div></body> which
Say I have a Telerik MVC Grid, AJAX bound and I want to put
Say I have a SSI script that uses exec, or a PHP script that
Say I have three tables, a table of users, a table of around 500
So say we you have a CSS property that is not inherited by default.
Lets say I have two divs How do I use .find to get div1's

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.