<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>跑马灯</title>
<script src="../js/jquery-1.9.1.min.js"></script>
<style>
.maxdiv {
border: 2px red solid;
width: 510px;
height: 510px;
margin: 15% auto;
}
.maxdiv div {
width: 83px;
height: 83px;
border: 1px blue solid;
float: left;
text-align: center;
line-height: 83px;
}
.hiddendiv {
visibility: hidden;
} .rightdiv {
clear: both;
float: right !important;
} .bottomdiv {
float: right !important;
} .leftdiv1 {
position: absolute;
margin-top: 339px;
} .leftdiv2 {
position: absolute;
margin-top: 254px;
} .leftdiv3 {
position: absolute;
margin-top: 171px;
} .leftdiv4 {
position: absolute;
margin-top: 86px;
} .startbtn {
position: absolute;
margin-left: 100px;
}
</style>
</head>
<body>
<div class="maxdiv">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div class="rightdiv"></div>
<div class="rightdiv"></div>
<div class="rightdiv"></div>
<div class="rightdiv"></div>
<div class="rightdiv"></div>
<div class="bottomdiv"></div>
<div class="bottomdiv"></div>
<div class="bottomdiv"></div>
<div class="bottomdiv"></div>
<div class="bottomdiv"></div>
<div class="leftdiv1"></div>
<div class="leftdiv2"></div>
<div class="leftdiv3"></div>
<div class="leftdiv4"></div>
<button class="startbtn">开始</button>
</div>
</body>
</html>
<script>
var i = 0,
num,
qs = 0,
timer1;
$(function () {
$(".startbtn").click(function () {
timer1 = setInterval(ttz, 100);
num = Math.floor(Math.random() * 20 + 1) + 1;
});
}); function ttz() {
if (i == 20) { i = 0; qs++; }//当i等于最大值的时候初始化为最小值,遍历次数加一
if (i < 20) {
if (qs >= 2 && i == num) { clearInterval(timer1); qs = 0; i = 0; return; }//当遍历次数大于2并且i等于随机数的时候,停止遍历
$(".maxdiv div").eq(i).css({ "background-color": "red" }).siblings().css({ "background-color": "#fff" });
}
i++;
}
</script>

样子有点戳,别见怪!O(∩_∩)O哈哈~

JQ跑马灯的更多相关文章

  1. jq跑马灯效果

    这几天公司产品有个无缝循环滚动的广告跑马灯要做,最开始想到的是<marquee>标签,但在PC端正常,在安卓广告屏上却怎么都跑不动,后来用的css3的animation,结果也是PC端及其 ...

  2. Android-TextView跑马灯效果

    要实现跑马灯还是比较简单的. 同时有几个需要注意的点,先上代码: public class MTView extends TextView { public MTView(Context contex ...

  3. jQuery+CSS3文字跑马灯特效

    jQuery+CSS3文字跑马灯特效是一款将跑马灯背景制作为3D立方体效果,文字在上面移动时,就像是文字投影到墙壁上,在转角出会改变运动方向. 效果展示 http://hovertree.com/te ...

  4. IOS跑马灯效果,实现文字水平无间断滚动

    ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController{ NSTimer ...

  5. 【IOS】自定义可点击的多文本跑马灯YFRollingLabel

    需求 项目中需要用到跑马灯来仅展示一条消息,长度合适则不滚动,过长则循环滚动. 虽然不是我写的,但看了看代码,是在一个UIView里面放入两个UILabel, 在前一个快结束的时候,另一个显示.然而点 ...

  6. Android:TextView文字跑马灯的效果实现

    解决TextView文字显示不全的问题. 简单设置跑马灯的效果: <TextView android:id="@+id/textView" android:layout_wi ...

  7. canvas九宫格跑马灯

    canvas九宫格跑马灯抽奖 之前用dom写了一版,部分 安卓机会卡顿,换用canvas dom版本九宫格抽奖

  8. Third Day:正式编程第三天,学习实践内容TextView跑马灯、AutoCompleteTextView、multiAutoCompleteTextView以及ToggleButton、checkedBox、RadioButton等相关实践

    2.针对Focused的TextView跑马灯(文字较多一行无法显示)效果 针对单个TextView的跑马灯效果,可直接在TextView控件参数中添加三个属性: android:singleLine ...

  9. TextView跑马灯效果

    转载:http://www.2cto.com/kf/201409/330658.html 一.只想让TextView显示一行,但是文字超过TextView的长度怎么办?在开头显示省略号 android ...

随机推荐

  1. 粒子系统1:简介&工具使用

    直接使用工具来感受一下粒子系统的强大威力吧. 网络上有很多粒子编辑器,大多数都是收费的.magicalsoft提供了一个免费的粒子编辑器(该工具目前只有mac版本),界面如下: 我们将针对这个编辑器来 ...

  2. 日志分析(四) Elasticsearch的精确查询

    在需要做精确查询时,往往不希望做全文模糊搜索,这时,需要告知Elasticsearch在处理我们提供的字符串时,需要做精确匹配. 此时,在需要做精确匹配的字符串上,加上””,如”/user/info” ...

  3. unix fopen和fopen_s用法的比较

    在定义FILE * fp 之后,fopen的用法是: fp = fopen(filename,"w").而对于fopen_s来说,还得定义另外一个变量errno_t err,然后e ...

  4. java_SSH整合1

    Domain: public class Department { private Long id; private Set<User> users = new HashSet<Us ...

  5. linux的rpm命令

    rpm 执行安装包二进制包(Binary)以及源代码包(Source)两种.二进制包可以直接安装在计算机中,而源代码包将会由 RPM自动编译.安装.源代码包经常以src.rpm作为后缀名. 常用命令组 ...

  6. 网卡及MAC和PHY的区别

    转载:http://blog.sina.com.cn/s/blog_53d7350f0100mudb.html 一块以太网网卡包括OSI(开方系统互联)模型的两个层.物理层和数据链路层.物理层定义了数 ...

  7. 刚安装完jdk和eclipse需要配置什么?

    还需要配置环境变量,你还要下载 apache-tomcat WEB服务器,也就是说 系统能找到你的 服务器,具体配置:(在windows桌面上右击“我的电脑” —> “属性” —> “高级 ...

  8. Python学习笔记 第二课 循环

    >>> movies=["The Holy Grail", 1975, "The Life of Brian", 1979, "Th ...

  9. iOS之原生地图与高德地图

    原生地图 1.什么是LBS LBS: 基于位置的服务 Location Based Service 实际应用:大众点评,陌陌,微信,美团等需要用到地图或定位的App 2.定位方式 1.GPS定位 2. ...

  10. CI加载流程小结

    无聊,决定水一把. CI(CodeIgniter)是我最早接触的一个框架,到现在也只是用了其中一点零碎的方法.一直想对其流程做个小结,却总是因各种各样的“理由”挨着.看见别人图表齐上阵,没那耐心,就从 ...