<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<title>jQuery UI模拟刮彩票涂层显示结果</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<style type="text/css">
#keleyi{width:200px;height:20px;position:relative;text-align:center;font-size:12px;overflow:hidden;background:#eee;}
#keleyi div{position:absolute;top:0px;left:0px;width:100%;height:20px;background:#ccc;}
#layout2{width:200px;height:20px;position:relative;text-align:center;font-size:12px;overflow:hidden;background:#eee;}
#layout2 div{position:absolute;top:0px;right:0px;width:100%;height:20px;background:#ccc;}
</style>
<script type="text/javascript" src="http://keleyi.com/keleyi/pmedia/jquery/jquery-1.11.0.min.js"></script>
<script src="http://keleyi.com/keleyi/pmedia/jquery/ui/1.10.3/js/jquery-ui-1.10.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#keleyi div").draggable({
revert:function() {
var a = $("#keleyi div").offset().left;
var b = $("#kel"+"eyi").width();
if (a >= b) {
$("#keley"+"i").text("恭喜您获得5000万美元大奖!").css("color","red").fadeOut(200).fadeIn(500);
return false;
}else{
return true;
}
},
axis: "x", snap: "#keleyi", scroll: false}
);
$("#layout2 div").click(function() {
$(this).animate({
width : "+=20",
}).animate({
width : "-=50",
});
if ($(this).width() <= 30) {
$("#layout2").text("恭喜您获得5000万美元大奖!").css("color","red").fadeOut(200).fadeIn(500);
}
});
});
</script>
</head>
<body>
<div>说明:不支持IE6!</div>
<p> </p>
<p>效果一(拖拽灰条):</p>
<div id="keleyi">
<div></div>
请完全刮开查看中奖结果。
</div>
<p> </p>
<p>效果二(点击灰条):</p>
<div id="layout2">
<div></div>
请完全刮开查看中奖结果。
</div>
<br />
</body>
</html>