jQuery炫酷名字闪烁随机点名代码

来源:https://www.sucaihuo.com/js/4260.html 2019-03-21 11:11浏览(1464) 收藏

一款实用的jQuery炫酷名字闪烁随机点名代码,点击开始点名,多组排列好的名字闪烁随机选中一个名字高亮突出显示。
jQuery炫酷名字闪烁随机点名代码
分类:其它特效 > jQuery插件 难易:初级
查看演示 下载资源 下载积分: 20 积分

js代码

<script type="text/javascript">
$(function() {
	var j = 0;
	$(document).on('selectstart', function() {
		return false
		})
		var timer,
		n = 0
		$('.box p').on('click', function() {
		if (j == 0) {
			j = 1;
			$(".but").html("点名中");
			timer = setInterval(function() {
				n++
		
				$('.box div').each(function(k, v) {
		
					$('.box div').eq(k).css({
						'background': color(),
						'color': color()
					})
				})
				console.log(n)
				if (n >= 20) {
		
					clearInterval(timer)
					j = 0;
					$(".but").html("开始点名");
					n = 0
					$('.box div').css({
						'background': 'orangered',
						'color': 'white'
					})
					$('.box div').eq(name()).css({
						'background': 'white',
						'color': 'blueviolet'
					})
				}
			}, 100)
		}
	})

	/*随机索引号,需要改的就直接改数字,多少人就改成多少个*/
	function name() {
		return Math.floor(Math.random() * 24)
	}
	/*随机的颜色封装函数*/
	function color() {
		var r = Math.floor(Math.random() * 256)
		var g = Math.floor(Math.random() * 256)
		var b = Math.floor(Math.random() * 256)
		return 'rgb(' + r + ',' + g + ',' + b + ')'
	}
})
</script>
标签: 随机点名名字
评论0
头像

系统已开启自动识别垃圾评论机制,识别到的自动封号,下载出错或者资源有问题请联系全栈客服QQ 1915635791

1 2