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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:51:31+00:00 2026-06-04T10:51:31+00:00

I have a div containing an image that can be dragged around inside the

  • 0

I have a div containing an image that can be dragged around inside the div to get the coordinates for the cropping of the image. I was able to get the right coordinates but as soon as I dragged the image to a certain position I cannot redrag to another position, if I don’t like the detail of the image… where do I go wrong… The final positions x + y will be saved into a hidden input… here’s my code:

    <!-- Div container 350x350px with border where detail of image can be chosen -->
<div id="draggable">
    <!-- Image (bigger than div draggable) that is draggable in the div -->
<img id="dragimg" src="<?php echo $path_to_image_directory.$filename; ?>" />
</div>


<script type="text/javascript">
    $(document).ready(function() {
        $("#dragimg").draggable({
            stop: function(){
                var finalxPos = $(this).css('left');
                var finalyPos = $(this).css('top');
                //  alert( "Drag stopped!\n\nOffset: (" 
                + finalxPos + ", " + 
                finalyPos + ")\n");
                $('#crop [name="finalX"]').val(finalxPos);
                $('#crop [name="finalY"]').val(finalyPos);
            }
        });
    });
</script>

Can you aid me in solving my issue?

  • 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-06-04T10:51:33+00:00Added an answer on June 4, 2026 at 10:51 am

    To get the absolute position in his parent is the .position()

    $('.object').bind('drag',function(){
    
     var obj = $(this);
     var position = obj.position();
     var leftpos = position.left;
     var toppos = position.top;
     });
    

    and you can add a input val function like

    <input type="text" name="top" id="topVal"/>
    

    and in the bind function

    $('#topVal').val(toppos);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a Div containing an iframe that I can Clone using JQuery.
I have a div that contains inside 3 'floated' divs. The containing div has
I have a DIV containing an image and a second DIV. The parent DIV
So I have 3 divs contained inside a containing div like such: <div id=contain>
I am building a page that will animate objects (image/shape/div) and float them around
I have a major headache trying to get an image that is contained within
as you can see in the following image, i have a simple form that
I have a div containing 2 paragraphs. I want the paragraphs to be aligned
Hey so I have a div containing 3 links which have a background url
I have a div element containing some text. When the user clicks a word

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.