<!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. 解决Mac下SublimeLinter的Unsafe Characters警告

    Mac下编辑JS文件, 如果是中文字符的行会警告: This character may get silently deleted by one or more browsers. SublimeLi ...

  2. apache 配置order allow deny讲解

    http://www.111cn.net/phper/apache/43025.htm

  3. Eclipse的java代码出错:The import org.apache cannot be resolved

    Eclipse中,折腾java代码. 把之前在android中的代码拿过来使用. 结果出现The import org.apache cannot be resolved的错误: [解决过程] 1.这 ...

  4. CCTableView的使用和注意事项

    #include "cocos-ext.h" using namespace cocos2d::extension; class TableViewTestLayer: publi ...

  5. UVA 539 The Settlers of Catan dfs找最长链

    题意:画边求最长链,边不能重复数点可以. 很水,用暴力的dfs即可,因为数据不大. 本来以为可以用floyd进行dp的,后来想想好像不能在有回路上的图跑...于是没去做. #include <c ...

  6. linux-软连接

    ln -s /opt/lampp/bin/mysql(绝对路径) /usr/local/bin(软连接目录或者文件) 如果不愿意配置环境变脸可以直接创建env查出的路径下建连接

  7. ES 父子文档查询

    父子文档的特点 1. 父/子文档是完全独立的. 2. 父文档更新不会影响子文档. 3. 子文档更新不会影响父文档或者其它子文档. 父子文档的映射与索引 1. 父子关系 type 的建立必须在索引新建或 ...

  8. 使用openoffice将word文件转换为pdf格式遇到问题:The type com.sun.star.lang.XEventListener cannot be resolved. It is indirectly referenced from required

    The type com.sun.star.lang.XEventListener cannot be resolved. It is indirectly referenced from requi ...

  9. LAMP平台搭建详解

    准备工作 安装编译工具 # yum -y install gcc # yum -y install gcc-c++ 如果系统之前已经安装有rpm包的mysql和apache,那么可以: #servic ...

  10. [改善Java代码]使用静态内部类提高封装性

    建议38: 使用静态内部类提高封装性 Java中的嵌套类(Nested Class)分为两种:静态内部类(也叫静态嵌套类,Static Nested Class)和内部类(Inner Class).内 ...