<!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. iOS开发——UI_swift篇&TableView实现页眉和页脚

    TableView实现页眉和页脚   在UItableView中header和footer是很常见的,而且他能让你实现很复杂的功能,我们见过最多的就是下拉刷新和上啦加载更多,当然你还可以在上面添加一个 ...

  2. Key Task

    Problem Description The Czech Technical University is rather old - you already know that it celebrat ...

  3. mysql 优化工具

    explain  profiling 建议提供以下信息 show table status like 'audit';show create table audit;show index from a ...

  4. Java_Utils框架

    Spring Utils https://github.com/tangyanbo/springmore

  5. IDEA 编译错误:java: try-with-resources is not supported in -source 1.6 (use -source 7 or higher to enable try-with-resources)

    错误描述 在用IDEA编译别人的项目的时候遇到下面的错误: java: try-with-resources is not supported in -source 1.6 (use -source ...

  6. 炼数成金hadoop视频干货04

    视频地址:http://pan.baidu.com/s/1dDEgKwD 这一节讲的全是理论 任务执行优化 : 1.推测式执行: 2.重用JVM: 3.忽略模式. 除了手动修改Log4J.proper ...

  7. Android(java)学习笔记70:同步中的死锁问题以及线程通信问题

    1. 同步弊端: (1)效率低 (2)如果出现了同步嵌套,就容易产生死锁问题 死锁问题及其代码 : (1)是指两个或者两个以上的线程在执行的过程中,因争夺资源产生的一种互相等待现象 (2)同步代码块的 ...

  8. Github 的一些基本操作

    1.创建一个新的repository: 先在github上创建并写好相关名字,描述.例如这样一个地址: https://github.com/test/test2.git 回到本地目录如hellowo ...

  9. jquery 页面跳转 表单提交

    $("#button").click(function () {            $("#form").first().attr("action ...

  10. 关于解决form表单记录上次保存填写记录清空

    传进来的是一个HTML的Table的ID. function doReset(tableId){ var tbl_content = document.getElementById(tableId); ...