I am facing a minor issue and I need some assistance in figuring out what I might be missing here.
Here is my html code:
<div class="drop-down-menu">
<div class="innerdrop-down-menu">
<div id="first-tab-cont">
<ul id="slider">
<li>...</li>
<li>...</li>
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
<a href="javascript:;" id="back">⇐</a>
<a href="javascript:;" id="forward">⇒</a>
</div>
</div>
</div>
The CSS code:
.drop-down-menu{ display:none; position:relative; background-color:#FFFFFF; width:100%; height:280px; z-index:2; }
#first-tab-cont{ background-color:#CCC; display:none; width:960px; height:240px; padding:20px; }
#slider{ background-color:#C9F; position:relative; min-width:100%; width:auto; height:240px; font-family: HelveticaNeue; white-space:nowrap; }
#slider li{ background-color:#C03; display:inline-block; margin-right:15px; white-space:nowrap; width:300px; height:240px; }
And the current jQuery code is:
var Min = 0;
var Max = $("#fifth-tab-cont #slider").width();
var Step = 300;
$("#first-tab-cont #back").click(function(){
if($("#first-tab-cont #slider").position().left <= Min + Step) {
$("#first-tab-cont #slider").animate({left: '+=300px'}, Step );
}
});
$("#first-tab-cont #forward").click(function(){
if($("#first-tab-cont #slider").position().left >= Max + Step) {
$("#first-tab-cont #slider").animate({left: '-=300px'}, Step );
}
});
I'm trying to determine the size of the slider
width in order to restrict scrolling only within its dimensions. How can I achieve this?