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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:34:07+00:00 2026-05-26T12:34:07+00:00

I have a DIV container which position is absolute and I’m having a draggable

  • 0

I have a DIV container which position is absolute and I’m having a draggable DIV with a textbox inside that DIV and now I need the textbox X and Y position.

As I do not want the browsers position to be set and I need to set the DIV position (0,0)

Whenever I drag the draggable div in the main DIV container I need the texbox position as of now if I drag and drop I get the browsers X and Y position

This is what I mean?

enter image description here

Here is my code:

 <script type="text/javascript">
        $(function () {

            $('.innercontainer').draggable({
                containment: '#maincontainer',
                cursor: 'move',
                snap: '#content',
                stop: function () {
                    var offset = $(this).offset();
                    var xPos = offset.left;
                    var yPos = offset.top;
                    $('#posX').text('X: ' + xPos);
                    $('#posY').text('Y: ' + yPos);
                }
            })
    .resizable();

        });

    </script>

Here is my container:

   <div id="maincontainer">

    <div class="innercontainer">
                                <asp:TextBox ID="TextBox1" TextMode="MultiLine"></asp:TextBox>
</div>
</div>

These are my labels where I’m showing the positions:

 <asp:Label ID="posX" runat="server" Width="80px">X:</asp:Label>
 <asp:Label ID="posY" runat="server" Width="80px">Y:</asp:Label>
  • 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-26T12:34:08+00:00Added an answer on May 26, 2026 at 12:34 pm

    If you need the input’s position relative to the #maincontainer div, you can do some simple math:

    var containerPos = $('#maincontainer').offset();
    var inputPos = $('.innercontainer input').offset();
    relativeOffset = { 
        top: inputPos.top - containerPos.top,
        left: inputPos.left - containerPos.left };
    $('#posX').text('X: ' + relativeOffset.left);
    $('#posY').text('Y: ' + relativeOffset.top);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a container div which is position:relative and the squares are position:absolute because
I have a jQuery draggable container div with a side scroll bar that should
I have a div which position is fixed, within that i have a div
I have a div container which contains 6 divs. I need to layout the
I have a fixed container and inside of that is an additional container which
I have a div which is position:fixed so that it it always in the
I have a container DIV which contains several block-DIVS. Every block-DIV contains SPAN items
Ok, I have a label, inside this label is a div, which contains an
I have a container div that holds two internal divs; both should take 100%
I have the following setup on 2 div tags: <div id='div1' style='position: absolute; z-index:

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.