遍历要抽奖人的头像(你可以把要抽奖的人的头像直接放在images文件下面)
$dir = "images/"; $img = ""; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) != false) { if ($file <> '' && strlen($file) > 2) { $img .= '"' . $file . '",'; } } } $img = substr($img, 0, ( strlen($img) - 1)); }
开始抽奖和停止抽奖js代码
function run() { if (!open) { timer = setInterval(change, 30); btn.removeClass('start').addClass('stop').text('停止'); open = true; } else { clearInterval(timer); btn.removeClass('stop').addClass('start').text('开始抽奖'); open = false; } } btn.click(function() { run(); })