<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="js/jquery-1.7.min.js"></script>
<title>左右点击幻灯片</title>
<style type="text/css">
*{margin: 0;padding: 0;}
ul{ list-style: none;}
.wrapper{width: 300px;height: 200px; margin:100px auto;overflow: hidden;border: 2px solid #ccc;position: relative;}
.scroll{width: 205px;margin: 0 auto; overflow: hidden;}
.scroll li{float: left; margin: 5px; height:160px; font-size:60px; text-align:center; line-height:100px; font-weight:800; background:#FF3F00; color:#fff; width:200px;}
.prev,.next{ width: 30px;height: 30px;background: #daa520;color: #fff;cursor: pointer;position: absolute;top:80px; text-align: center;line-height: 30px;}
.next{ right: 0;}
</style>
</head>
<script>
$(function(){
var oScroll=$('.scroll>ul'),oLi=oScroll.find('li'),oLen=oLi.length,oPrev=$('.prev'),oNext=$('.next'),oWidth=oLi.eq(0).outerWidth(true),iNow= 1,oCur=$('.count>em'),oCount=$('.count>i'),iTimer=null;
oScroll.width(oWidth*oLen);
oCount.html(oLen);
function count(){
oCur.html(iNow);
}
function Prev(){
oScroll.css({marginLeft:-oWidth+'px'}).find('li:last').prependTo(oScroll);
oScroll.stop(true,true).animate({marginLeft:0+'px'},600);
iNow=iNow>1?iNow-1:oLen;
count(iNow);
}
function Next(){
oScroll.stop(true,true).animate({marginLeft:-oWidth+'px'},600,function(){
oScroll.css({marginLeft:0}).find('li:first').appendTo(oScroll);
})
iNow=iNow<oLen?iNow+1:1;
count(iNow);
}
oPrev.bind('click',Prev);
oNext.bind('click',Next);
iTimer=setInterval(Next,3000);
$('.wrapper').hover(function(){
clearInterval(iTimer);
},function(){
iTimer=setInterval(Next,3000);
})
})
</script>
<body>
<div class="wrapper">
<span class="prev">《</span>
<span class="next">》</span>
<div class="scroll">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
<div class="count"><em>1</em>/<i>0</i></div>
</div>
</body>
</html>

jq左右按钮点击幻灯片的更多相关文章

  1. jq实现 按钮点击一次后 3秒后在可点击

    if(printRemind(selectPrintTemplate,selectOrders,orderStatus,isPreview)) //调用打印数据并打印 ajaxDataAndDoPri ...

  2. Runtime应用防止按钮连续点击 (转)

    好久之前就看到过使用Runtime解决按钮的连续点击的问题,一直觉得没啥好记录的.刚好今天旁边同时碰到这个问题,看他们好捉急而且好像很难处理,于是我先自己看看… 前面自己也学习了很多Runtime的东 ...

  3. android 自定义控件——(五)按钮点击变色

    ----------------------------------按钮点击变色(源代码下有属性解释)------------------------------------------------- ...

  4. UI-切圆角、透明度、取消按钮点击高亮效果、按钮文字带下划线

    一.切UIView的某个角为圆角 如果需要将UIView的4个角全部都为圆角,做法相当简单,只需设置其Layer的cornerRadius属性即可(项目需要使用QuartzCore框架).而若要指定某 ...

  5. 友盟(Swift)-集成、统计用户数量、具体页面访问数量、具体按钮点击数量

    什么是友盟.有什么用? 这些傻瓜问题这里就不解释了,可以自己百度去. 友盟提供的文档和demo都是oc的,这里用swift写了一个小demo,在此分享一下. 步骤1:友盟后台注册应用(iOS),拿到a ...

  6. js触发按钮点击事件

    js触发按钮点击事件 博客分类: javascript   模拟JS触发按钮点击功能 <html> <head> <title>usually function&l ...

  7. React初识(按钮点击+输入绑定)

    简单按钮点击事件: <!DOCTYPE html><html>  <head>  <meta charset="utf-8">    ...

  8. android 按钮点击效果实现

    在其他人的博客里看到其实实现按钮点击效果的方法有很多,这里提到的只是其中一个办法 图片素材(我自己用截图截的,可以自己搞) 放到mipmap目录下(studio是在这个目录下 , eclipse 直接 ...

  9. 按钮点击事件,打开新的Activity

    按钮点击事件,打开新Activity, 打开网页 findViewById(R.id.btnStartBAty).setOnClickListener(new View.OnClickListener ...

随机推荐

  1. Android4.4的zygote进程(上)

    1背景 前些天为了在科室做培训,我基于Android 4.4重新整理了一份关于zygote的文档.从技术的角度看,这几年zygote并没有出现什么大的变化,所以如果有人以前研究过zygote,应该不会 ...

  2. WebView中input file的解决方法

    public class MyWb extends Activity { /** Called when the activity is first created. */ WebView web; ...

  3. layui的时间线当点击按钮的时候自动添加一条新时间线

    $('.littleTaskBtn li').on('click',function(){ var content=$('.content').html(); $('.layui-timeline-i ...

  4. 跟着百度学PHP[15]-session回收机制

    gc(Garbage Collection 垃圾回收) 在用户访问的时候会生成许多的临时session文件,顾名思义session回收机制就是用来删除这些临时文件的. session.gc_maxli ...

  5. jQuery 时间戳转化成时间

    //时间转换  function   formatDate(now)   { var   now= new Date(now);      var   year=now.getFullYear();  ...

  6. ubuntun 下安装 node-v0.10.26

    sudo apt-get install g++ curl libssl-dev apache2-utils wget http://nodejs.org/dist/v0.10.26/node-v0. ...

  7. 一个IDEA和jackson结合的一个错误异常

    一个字段是isSend,用IDEA自动生成的getter/setter方法名会把is去掉.变成getSend()/setSend(). 当返回的时候使用Jackson转json的时候,就会把isSen ...

  8. Meter and pixel units in a box2d game - LibGDX

    http://pimentoso.blogspot.com/2013/01/meter-and-pixel-units-in-box2d-game.html 需FQ ————————————————— ...

  9. C++ 类的多态五(多态的语法本质分析)

    //多态的语法本质分析 #include<iostream> using namespace std; /* 三种易混淆的多态场景 */ class Point{ public: Poin ...

  10. 【BZOJ】3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队(dp)

    http://www.lydsy.com/JudgeOnline/problem.php?id=3400 既然是倍数我们转换成mod.. 设状态f[i][j]表示前i头牛modj的方案 那么答案显然是 ...