当前动画直接到达末状态
$(".num").each(function(index){ //判断是否处于动态 if($(this).is(":animated")){ //停止 $(this).stop(false,true).animate(); //当前动画直接到达末状态 } });
获取数组中的随机数
function numRand() { var num =Surplusnums[Math.floor(Math.random()*Surplusnums.length)]; return num; }
判断浏览器是否支持 localStorage
function isLocalStorage() { var testKey = 'test', storage = window.localStorage; try { storage.setItem(testKey, 'testValue'); storage.removeItem(testKey); return true; } catch (error) { return false; } }
localStorage使用:
//获取已经摇号的结果及剩余的 Surplusnums = localStorage.getItem("Surplusnums").split(","); selectnums = localStorage.getItem("selectnums").split(",");
------------------------
//保存结果信息
localStorage.setItem("Surplusnums", Surplusnums);
localStorage.setItem("selectnums", selectnums);
//从剩余的数字中删除抽中的数字 for(var i=0;i<Surplusnums.length;i++) { if(Surplusnums[i]==iNum) { Surplusnums.splice(i, 1); break; } } //将抽中的数字加入到已选 selectnums.push(getdate()+"!"+iNum);