jquery求大神去重或者生成不重复数组
</style></head><body><divclass="main_bg"><divclass="main"><divid="res"style="text-ali...
</style>
</head>
<body>
<div class="main_bg">
<div class="main">
<div id="res" style="text-align:center;color:#fff;padding-top:15px;"></div>
<div class="num_mask"></div>
<div class="num_box">
<div class="num"></div>
<div class="num"></div>
<div class="num"></div>
<div class="btn"></div>
</div>
</div>
</div>
<div style="text-align:center;">
<p>来源:<a>测试</a></p>
</div>
</body>
</html>
<script>
function numRand() {
var x = 999;
var y = 111;
var rand = parseInt(Math.random() * (x - y + 1) + y);
return rand;
}
var isBegin = false;
$(function(){
var u = 200;
$('.btn').click(function(){
if(isBegin) return false;
isBegin = true;
$(".num").css('backgroundPositionY',0);
var result = numRand();
$('#res').text('测试结果 = '+result);
var num_arr = (result+'').split('');
$(".num").each(function(index){
var _num = $(this);
setTimeout(function(){
_num.animate({
backgroundPositionY: (u*60) - (u*num_arr[index])
},{
duration: 600+index*300,
easing: "easeInOutCirc",
complete: function(){
if(index==2) isBegin = false;
}
});
}, index * 300);
});
});
});
</script> 展开
</head>
<body>
<div class="main_bg">
<div class="main">
<div id="res" style="text-align:center;color:#fff;padding-top:15px;"></div>
<div class="num_mask"></div>
<div class="num_box">
<div class="num"></div>
<div class="num"></div>
<div class="num"></div>
<div class="btn"></div>
</div>
</div>
</div>
<div style="text-align:center;">
<p>来源:<a>测试</a></p>
</div>
</body>
</html>
<script>
function numRand() {
var x = 999;
var y = 111;
var rand = parseInt(Math.random() * (x - y + 1) + y);
return rand;
}
var isBegin = false;
$(function(){
var u = 200;
$('.btn').click(function(){
if(isBegin) return false;
isBegin = true;
$(".num").css('backgroundPositionY',0);
var result = numRand();
$('#res').text('测试结果 = '+result);
var num_arr = (result+'').split('');
$(".num").each(function(index){
var _num = $(this);
setTimeout(function(){
_num.animate({
backgroundPositionY: (u*60) - (u*num_arr[index])
},{
duration: 600+index*300,
easing: "easeInOutCirc",
complete: function(){
if(index==2) isBegin = false;
}
});
}, index * 300);
});
});
});
</script> 展开
1个回答
展开全部
var INDEXS = [];
function numRand() {
var x = 999;
var y = 111;
var str = ","+INDEXS.join(",")+",";
var rand = parseInt(Math.random() * (x - y + 1) + y);
while (str.indexOf(","+rand+",") != -1){
rand = parseInt(Math.random() * (x - y + 1) + y);
}
return rand;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询