Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi dears,
i want calculate the left and top of picture that insert in image button,for process
thanks
Posted
Comments
Nilesh Patil Kolhapur 10-Feb-12 5:57am    
review your Question
OriginalGriff 10-Feb-12 6:13am    
Sorry, but that doesn't make any sense. You have to remember that we can't see your screen, your HDD or read your mind, so we only have the information in your question to work on.
Use the "Improve question" widget to edit your question and provide better information.
Christian Graus 10-Feb-12 7:53am    
You want the left and top what ? button position ? Image position in the button ?

1 solution

I would advise to use jQuery and its method .offset() which returns the current position of any element relative to document:
JavaScript
imgElement = $("#myImage");
elementPosition = imgElement.offset();
top = elementPosition.top;
left = elementPosition.left;


Please see http://api.jquery.com/offset/[^].
In this example, the img element is selected by its id attribute value "myImage":
HTML
<img alt="some image" src="someURL.png" id="myImage" />


For other selectors, please see http://api.jquery.com/category/selectors/[^].

See also position relative to a parent element, good to know: http://api.jquery.com/position/[^].

To learn about jQuery, please see:
http://en.wikipedia.org/wiki/JQuery[^],
http://jquery.com/[^],
http://docs.jquery.com/Main_Page[^].

—SA
 
Share this answer
 
v3
Comments
Espen Harlinn 11-Feb-12 5:08am    
5'ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900