这是一个电脑端跟手机端都适用的jquery机选彩票随机滚动效果,例中包含:双色球、大乐透、11选5随机选号js代码效果,更多的效果可根据实例自行开发。
JS代码
<script type="text/javascript">
/**
* Code Width jQuery
*
*/
/**
* [sn_Lottery_choose description]
* @param {[type]} elem [外层box]
* @param {[type]} numBox [滚动数字box]
* @param {[type]} count [最大数字限制]
* @return {[type]} [function]
*/
var sn_Lottery_choose = function(elem, numBox, count){
var Num = $(elem);
var arrBall = [];
var interval, index, i = 0;
for(var i = 1; i < count; i++){
arrBall.push(i);
}
arrBall.sort(function(){return (Math.random()<0.5?1:-1)});
function setNum(){
Num.find(numBox).each(function(){
index = arrBall[Math.floor(Math.random() * (count - 1))];
$(this).val(index);
});
i++;
if( i > count + 15){
arrBall.sort(function(){return (Math.random()<0.5?1:-1)});
for(var j = 0; j < Num.find(numBox).length; j++){
Num.find(numBox).eq(j).val(arrBall[j]);
}
return;
}
setTimeout(arguments.callee,10);
}
setNum();
Num.find(numBox).each(function(){
$(this).blur(function(){
if(parseInt($(this).val()) > (count - 1)){
alert("请输入小于" + (count - 1) + "的数字!")
$(this).val("");
}
});
});
}
function re_choose_number(redball, blueball){
sn_Lottery_choose(redball.id, redball.cls, redball.count);
if(typeof blueball != "object"){return;}
sn_Lottery_choose(blueball.id, blueball.cls, blueball.count);
}
function clean_choose_number(id){
$(id).find("input").val("");
}
/**
* [sn_Tabs description]
* @param {[type]} elem [触发元素]
* @param {[type]} box [选项卡容器]
* @param {[type]} boxclass [选项卡对应容器class]
* @param {[type]} type [触发类型]
* @param {[type]} more [是否有更多选项]
* @return {[type]} []
*/
function sn_Tabs(elem, box, boxclass, type, more){
var para = arguments;
var timeout;
$(elem).find("li").bind(type, function(){
var _this = $(this);
var i = $(this).index();
timeout = setTimeout(function(){
_this.addClass("cur").siblings().removeClass("cur");
$(box).find(boxclass).eq(i).show().siblings().hide();
if(para.length > 5){
//sn_Lottery_choose
var arr = [
{
id : "#ssq_choose",
cls : ".redball",
count : 34,
blueball : {
id : "#ssq_choose",
cls : ".blueball",
count : 17
}
},
{
id : "#dlt_choose",
cls : ".redball",
count : 36,
blueball : {
id : "#dlt_choose",
cls : ".blueball",
count : 13
}
},{
id : "#ssxw_choose_ball",
cls : ".redball",
count : 12
}
];
re_choose_number(arr[i], arr[i].blueball);
if(i == $(elem).find("li").length - 1){
sn_Tabs("#sswx_buy_tag", "#ssxw_choose_ball", ".buy_type_index_ball", "mouseover");
}
}
if(box == "#ssxw_choose_ball"){
//type = false;
sn_Lottery_choose("#ssxw_choose_ball", ".redball", 12);
}
},300);
});
$(elem).find("li").bind("mouseout", function(){
clearTimeout(timeout)
})
if(box == "#sn_buy_box"){
sn_Lottery_choose("#ssq_choose", ".redball", 34);
sn_Lottery_choose("#ssq_choose", ".blueball", 17);
sn_Lottery_random_clean();
}
}
function sn_Lottery_random_clean(){
$("#ssq_random").click(function(){
sn_Lottery_choose("#ssq_choose", ".redball", 34);
sn_Lottery_choose("#ssq_choose", ".blueball", 17);
});
$("#ssq_clean").click(function(){
clean_choose_number("#ssq_choose");
});
$("#dlt_random").click(function(){
sn_Lottery_choose("#dlt_choose", ".redball", 36);
sn_Lottery_choose("#dlt_choose", ".blueball", 13);
});
$("#dlt_clean").click(function(){
clean_choose_number("#dlt_choose");
});
$("#ssxw_random").click(function(){
sn_Lottery_choose("#ssxw_choose_ball", ".redball", 12);
});
$("#ssxw_clean").click(function(){
clean_choose_number("#ssxw_choose_ball");
});
}
$(function(){
sn_Tabs("#buy_tag", "#sn_buy_box", ".sn_buy_box", "mouseover", 0, 1);
});
</script>
系统已开启自动识别垃圾评论机制,识别到的自动封号,下载出错或者资源有问题请联系全栈客服QQ 1915635791