【实例简介】
【实例截图】
【核心代码】
Lottery Demobody{
height:1000px;
}
#lotteryContainer {
position:relative;
width: 300px;
height:100px;
}
#drawPercent {
color:#F60;
}
刷新彩票已刮开 0% 区域。
window.onload = function () {
var lottery = new Lottery('lotteryContainer', '#CCC', 'color', 300, 100, drawPercent);
lottery.init('http://www.baidu.com/img/bdlogo.gif', 'image');
document.getElementById('freshBtn').onclick = function() {
drawPercentNode.innerHTML = '0%';
lottery.init(getRandomStr(10), 'text');
}
var drawPercentNode = document.getElementById('drawPercent');
function drawPercent(percent) {
drawPercentNode.innerHTML = percent '%';
}
}
function getRandomStr(len) {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < len; i )
text = possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}