How to get the xy coordinate of an image=(0,0) from in the Big box(div)
- by Farah fathiah
I have a problem..I'm using visual studio 2008...
I want to ask, how to get the xy coordinate of an image=(0,0) from in the Big box(div)??? because when the image is drag to the end of the box it will give me x=8 and y=8...instead of x=0 and y=0...
Please help me!!! Tq...
Here is the code:
$('#dragThis').draggable({
cursor: 'move', // sets the cursor apperance
containment: '#box',
drag: function() {
var offset = $(this).offset();
var xPos = Math.abs(offset.left);
var yPos = Math.abs(offset.top);
$('#posX').text('x: ' + xPos);
$('#posY').text('y: ' + yPos);
},
stop: function(event, ui) {
// Show dropped position.
var Stoppos = $(this).position();
var left = Math.abs(Stoppos.left);
var top = Math.abs(Stoppos.top);
$('#posX').text('left: ' + left);
$('#posY').text('top: ' + top);
}
});
http://jsfiddle.net/qx5K7/