Reputation: 418
I have a 9000px horizontal div container and I want to find it's middle part.
I have this code but its getting the whole width of the window not the container div.
$(document).ready(function(){
scrollTo(($(document).width() - $(window).width()) / 2, 0);
});
Here's a jsFiddle of the whole code
Upvotes: 0
Views: 121
Reputation: 4617
It should not be $(document) instead if the id of the 9000px div is #long_div, see the code below.
$(document).ready(function(){
scrollTo($("#long_div").width()/2, 0);
});
Upvotes: 2