My image is embedded in a table cell. I need to know how far it is from edge of window.
offsetLeft does not work for this. Neither does style.left.

Here is a simple example... seems to work. show your relevant code..maybe you have some other issue.

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
var i = $( "#img1" );
var offset = i.offset();
$("#pos").text( "left: " + offset.left + ", top: " + offset.top );

});
</script>
</head>
<body>     
<span id="pos"></span>
<img id="img1" src="" width="250" height="250" style="position:fixed;top:50px;left:50px"/>
</body>
</html>

Thank you. Your code is very helpful.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.