<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<script type="text/javascript">
function animate(dir, step) {
var position;
position = parseInt($("#content").css("margin-left"));
var contentwidth;
var sliderwidth;
contentwidth = parseInt($("#content").css("width"));
sliderwidth = parseInt($("#slider").css("width"));
//alert(position);
switch (dir) {
case "right":
position = ((position - step) < (sliderwidth - contentwidth)) ? (sliderwidth - contentwidth) : (position - step);
break;
case "left":
position = ((position + step) > 0) ? 0 : (position + step);
break;
default:
break;
};
//alert(position);
$("#content").animate(
{ marginLeft: position + "px" },
800
);
}
$(document).ready(function() {
$("#slider").css("width", ($("body").attr("clientWidth") - 80) + "px");
$("#leftA").click(function() {
animate("left", 400);
});
$("#rightA").click(function() {
animate("right", 400);
});
});
</script>
<style type="text/css">
ul,li{
display:block;
}
li{
width:150px;
float:left;
}
#content
{
width: 2030px;
margin-left: 0px;
}
#slider
{
margin-left: 40px;
overflow: hidden;
}
#leftA
{
display: block;
float: left;
left: 10px;
top: 5px;
position: absolute;
background-image: url();
}
#rightA
{
display: block;
float: right;
right: 10px;
top: 5px;
position: absolute;
background-image: url();
}
</style>
<body>
<div class="title_bar">
<a id="leftA" href="javascript:void(0);" >
left
</a>
<div id="slider">
<div id="content">
<ul id="Ul1" class="tab_nav" style="margin-left: 0px; margin-right: 0px;">
<li id="gaom1" class="menuon" >
基本信息</li>
<li id="gaom2" class="menuoff" >
基本信息</li>
<li id="gaom3" class="menuoff" >
基本信息</li>
<li id="gaom4" class="menuoff" >
基本信息</li>
<li id="gaom5" class="menuoff" >
基本信息</li>
<li id="gaom6" class="menuoff" >
基本信息</li>
<li id="gaom7" class="menuoff" >
基本信息</li>
<li id="gaom8" class="menuoff" >
基本信息</li>
<li id="gaom9" class="menuoff" >
基本信息</li>
<li id="gaom10" class="menuoff" >
基本信息</li>
<li id="gaom11" class="menuoff" >
基本信息</li>
</ul>
</div>
</div>
<a id="rightA" href="javascript:void(0);" >
right</a>
</div>
</body>
jQuery slider Content
最新推荐文章于 2024-08-30 20:29:15 发布