Offset is returning null, why?
In my actual web page offset() was returning values that were much too high. Yet when I tried to recreate a simple example offset() now returns null. Below is the code and markup. Any ideas.
Thanks,
Jason
http://jsbin.com/udowu
- <style>
.header{
height: 65px;
background-color: #3A4a5d;
width: 100%;
margin-bottom: 10px;
}
.menu{
background-color:#F6F6F6;
float: left;
height: 400px;
padding: 5px;
position: absolute;
width: 200px;
}
.content{
margin-left: 225px;
}
.section{
margin-top: 15px;
background-color: grey;
}
</style>
</head>
<body>
<div class="header">Header</div>
<div class="menu">Sidebar</div>
<div class="content">Content
<div class="section">section 1</div>
<div class="section">section 2</div>
<div class="section">section 3</div>
</div>
</body>
- $(document).ready(function(){
var s = $(".section :last");
var offset = s.offset();
alert(offset);
});