jq左右按钮点击幻灯片
<!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左右按钮点击幻灯片的更多相关文章
- jq实现 按钮点击一次后 3秒后在可点击
if(printRemind(selectPrintTemplate,selectOrders,orderStatus,isPreview)) //调用打印数据并打印 ajaxDataAndDoPri ...
- Runtime应用防止按钮连续点击 (转)
好久之前就看到过使用Runtime解决按钮的连续点击的问题,一直觉得没啥好记录的.刚好今天旁边同时碰到这个问题,看他们好捉急而且好像很难处理,于是我先自己看看… 前面自己也学习了很多Runtime的东 ...
- android 自定义控件——(五)按钮点击变色
----------------------------------按钮点击变色(源代码下有属性解释)------------------------------------------------- ...
- UI-切圆角、透明度、取消按钮点击高亮效果、按钮文字带下划线
一.切UIView的某个角为圆角 如果需要将UIView的4个角全部都为圆角,做法相当简单,只需设置其Layer的cornerRadius属性即可(项目需要使用QuartzCore框架).而若要指定某 ...
- 友盟(Swift)-集成、统计用户数量、具体页面访问数量、具体按钮点击数量
什么是友盟.有什么用? 这些傻瓜问题这里就不解释了,可以自己百度去. 友盟提供的文档和demo都是oc的,这里用swift写了一个小demo,在此分享一下. 步骤1:友盟后台注册应用(iOS),拿到a ...
- js触发按钮点击事件
js触发按钮点击事件 博客分类: javascript 模拟JS触发按钮点击功能 <html> <head> <title>usually function&l ...
- React初识(按钮点击+输入绑定)
简单按钮点击事件: <!DOCTYPE html><html> <head> <meta charset="utf-8"> ...
- android 按钮点击效果实现
在其他人的博客里看到其实实现按钮点击效果的方法有很多,这里提到的只是其中一个办法 图片素材(我自己用截图截的,可以自己搞) 放到mipmap目录下(studio是在这个目录下 , eclipse 直接 ...
- 按钮点击事件,打开新的Activity
按钮点击事件,打开新Activity, 打开网页 findViewById(R.id.btnStartBAty).setOnClickListener(new View.OnClickListener ...
随机推荐
- Tokyo Tyrant(TTServer)系列(六)-数据丢失谁的错
,false,1,100);$mem->addServer ("127.9.9.1",1978,false,1,100);$start=microtime(true);for ...
- container_of学习笔记
最近在学习c语言宏编程,看到了container_of宏,深入学习了一天,做个笔记留念. 1.看一下书上写的container_of的版本: #define offsetof(TYPE,MEMBER) ...
- application/x-www-form-urlencoded接口响应报文中文乱码
1.如何处理乱码 在进行接口测试时,在用httpclient post请求时,对于Content-Type:application/json来说,在写测试脚本时只需要为头信息和post请求指定相应编码 ...
- PHP学习笔记(3)GD库画图
<?php //加header头,不然浏览器乱码 header("content-type: image/png"); //创建画布资源 $img = imagecreate ...
- POSTGRESQL 9.1 FATAL: password authentication failed for user "postgres"
1.配置postgreql 可以远程访问: sudo vim /etc/postgresql/9.1/main/postgresql.conf root@ubuntuserver:~# sudo vi ...
- SSH初体验系列--Hibernate--3--单值与分页查询
前言 查询可以按结果集分2类:单个结果 和 数组 ; 其中,返回数组,在这个 数据库数据量随随便便就能上几十万的互联网时代大背景下,常常需要做分页处理, 所以这里就说一下单值和分页, 算是对上一篇&q ...
- jquery.js:8672 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
html5谷歌流浪器报错:jquery.js:8672 Synchronous XMLHttpRequest on the main thread is deprecated because of i ...
- jquery添加!important样式
$("span.colorFlag").parents("th").css("cssText","background-color ...
- Img src用base64数据
<img src='data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgG ...
- php中数组中&的问题
1.代码: <?php $arr = array('one','two','three'); foreach ($arr as $value){ echo 'Value:'.$value.'&l ...