First you need to refactor your html like;
<a href="#" data-id="-450" class="paginate">Move to first div</a>
<a href="#" data-id="0" class="paginate">Move to center</a>
<a href="#" data-id="+450" class="paginate">Move to 3rd div</a>
<div id="main-wrapper">
<div id="inner-wrapper">
<ul>
<li><div id="div1" class="divstyle">this is first</div></li>
<li><div id="div2" class="divstyle">this is second</div></li>
<li><div id="div3" class="divstyle">this is third</div></li>
</ul>
</div>
</div>
As you can see I have put position value in data-id
, and added #
to href links. And your js will be;
$('.paginate').click(function(event) {
event.preventDefault();
var amount = $(this).data("id");
$("#main-wrapper").animate({
left: amount
}, 1000, function() {
});
});