jQuery Style How to - Get left offset








Question

We would like to know how to get left offset.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.7.1.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--  w  ww .  j a  v a  2  s . c o  m-->
    var left = $("#result").css("left");
    console.log(left);
});
</script>
</head>
<body>
  <div id="result" style="left: 10px; position: absolute;"></div>
</body>
</html>

The code above is rendered as follows: