troubleshooting Question

jquery coordinates of element from bottom right

Avatar of Steve Tinsley
Steve TinsleyFlag for United Kingdom of Great Britain and Northern Ireland asked on
JavaScriptjQuery
5 Comments1 Solution551 ViewsLast Modified:
I want to create a script where the user can drag a dot on a grid (starting at bottom left).
I have started by using jQuery UI draggable and can access the coordinates from top left...

See below:

<script>


$(document).ready(function() {

$('#dragThis').draggable(
    {    containment: "#grid", scroll: false,

        drag: function(){
			

            var offset = $(this).offset();
            var xPos = offset.left;
            var yPos = offset.top;
            $('#posX').text('x: ' + xPos);
            $('#posY').text('y: ' + yPos);
			
			

        }
    });
});
	
	
	
</script>

I want to beable to get the coords from bottom left... See example emage below...

grid example
Eventually I want the 2 coords in a form textbox seperated by a comma. This will then be submitted to a database.

Could anyone help?

Steve
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros