jquery實(shí)現(xiàn)的圖片點(diǎn)擊滾動效果
更新時(shí)間:2014年04月29日 16:01:24 作者:
這篇文章主要介紹了jquery實(shí)現(xiàn)的圖片點(diǎn)擊滾動效果,需要的朋友可以參考下
需要添加jquery文件才可以調(diào)試
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function(){
//alert($('#findclose').closest('div').attr('id'));
var pic_length = $('#gd li').length;
var n = 0;
$('#toleft').click(function(){
if (!$('#gd').is(':animated') && n)
{
$('#gd').animate({left:'+=120px'},500);
n--;
}
});
$('#toright').click(function(){
if (!$('#gd').is(':animated') && pic_length > n+5)
{
$('#gd').animate({left:'-=120px'},500);
n++;
}
});
})
</script>
<style type="text/css">
ul{
list-style:none;
margin:0px;
padding:0px;
text-align:center;
}
#gd li {
width:90px;
height:80px;
display:block;
float:left;
margin:9px 15px;
}
</style>
<div style="width:702px;height:100px;background:#ccc;margin:0 auto">
<div style="width:30px;height:30px;background:red;margin:35px 10px;float:left;cursor:pointer;" id="toleft"></div>
<div style="width:600px;height:98px;float:left;border:1px solid #777;overflow: hidden;">
<ul style="list-style: none outside none;height:98px;display:block;background:yellow;position:relative;width:9999em;" id="gd">
<li style="background:red"></li>
<li style="background:orange"></li>
<li style="background:green"></li>
<li style="background:navy"></li>
<li style="background:blue"></li>
<li style="background:purple"></li>
<li style="background:pink"></li>
<li style="background:gray"></li>
</ul>
</div>
<div style="width:30px;height:30px;background:red;margin:35px 10px;float:left;cursor:pointer;" id="toright"></div>
</div>
復(fù)制代碼 代碼如下:
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function(){
//alert($('#findclose').closest('div').attr('id'));
var pic_length = $('#gd li').length;
var n = 0;
$('#toleft').click(function(){
if (!$('#gd').is(':animated') && n)
{
$('#gd').animate({left:'+=120px'},500);
n--;
}
});
$('#toright').click(function(){
if (!$('#gd').is(':animated') && pic_length > n+5)
{
$('#gd').animate({left:'-=120px'},500);
n++;
}
});
})
</script>
<style type="text/css">
ul{
list-style:none;
margin:0px;
padding:0px;
text-align:center;
}
#gd li {
width:90px;
height:80px;
display:block;
float:left;
margin:9px 15px;
}
</style>
<div style="width:702px;height:100px;background:#ccc;margin:0 auto">
<div style="width:30px;height:30px;background:red;margin:35px 10px;float:left;cursor:pointer;" id="toleft"></div>
<div style="width:600px;height:98px;float:left;border:1px solid #777;overflow: hidden;">
<ul style="list-style: none outside none;height:98px;display:block;background:yellow;position:relative;width:9999em;" id="gd">
<li style="background:red"></li>
<li style="background:orange"></li>
<li style="background:green"></li>
<li style="background:navy"></li>
<li style="background:blue"></li>
<li style="background:purple"></li>
<li style="background:pink"></li>
<li style="background:gray"></li>
</ul>
</div>
<div style="width:30px;height:30px;background:red;margin:35px 10px;float:left;cursor:pointer;" id="toright"></div>
</div>
相關(guān)文章
JavaScript導(dǎo)航腳本判斷當(dāng)前導(dǎo)航
這篇文章主要介紹了JavaScript導(dǎo)航腳本判斷當(dāng)前導(dǎo)航的相關(guān)資料,非常不錯,具有參考借鑒價(jià)值,需要的朋友可以參考下2016-07-07js實(shí)現(xiàn)瀑布流的一種簡單方法實(shí)例分享
現(xiàn)在說瀑布流式布局似乎有點(diǎn)晚了,但是每一項(xiàng)技術(shù)都是向著“精”和“簡”的方向在不斷發(fā)展,在發(fā)展到極致之前,需要一個相當(dāng)漫長的過程,因此,從這個角度來說,當(dāng)瀑布流被應(yīng)用得越來越多的時(shí)候,反而更應(yīng)該討論它,討論如何將它改善2013-11-11javascript實(shí)現(xiàn)TreeView 無刷新展開的實(shí)例代碼
這篇文章介紹了javascript實(shí)現(xiàn)TreeView 無刷新展開的實(shí)例代碼,有需要的朋友可以參考一下2013-07-07淺談JavaScript的innerWidth與innerHeight
下面小編就為大家?guī)硪黄獪\談JavaScript的innerWidth與innerHeight。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-10-10CSS中position屬性之fixed實(shí)現(xiàn)div居中
這篇文章主要介紹了CSS中position屬性之fixed實(shí)現(xiàn)div居中的相關(guān)資料,需要的朋友可以參考下2015-12-12