ITPub博客

首页 > IT职业 > IT图书 > jQuery刮彩票兑奖效果

jQuery刮彩票兑奖效果

原创 IT图书 作者:chunzhisu 时间:2014-07-17 10:06:38 0 删除 编辑
  • jQuery刮彩票兑奖效果,很有意思的代码,用鼠标拖动灰度条向右滑开,可看到中奖信息,还有一种效果是,完全撕开查看中奖结果,这功能酷吧,不过有些遗憾,IE6不兼容本效果,请使用IE8或火狐、Chrome等浏览器。

点击(此处)折叠或打开

  1. <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
  2. <html xmlns=\"http://www.w3.org/1999/xhtml\">
  3. <head>
  4. <title>jQuery刮彩票兑奖效果</title>
  5. <meta http-equiv=\"content-type\" content=\"text/html;charset=gb2312\">
  6. <style type=\"text/css\">
  7. #layout{width:200px;height:20px;position:relative;text-align:center;font-size:12px;overflow:hidden;background:#eee;}
  8. #layout div{position:absolute;top:0px;left:0px;width:100%;height:20px;background:#ccc;}
  9. #layout2{width:200px;height:20px;position:relative;text-align:center;font-size:12px;overflow:hidden;background:#eee;}
  10. #layout2 div{position:absolute;top:0px;right:0px;width:100%;height:20px;background:#ccc;}
  11. </style>
  12. <script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js\"></script>
  13. <script src=\"/ajaxjs/jquery-ui-1.8.20.min.js\" type=\"text/javascript\"></script>
  14. <script type=\"text/javascript\">
  15. $(document).ready(function() {
  16.     $(\"#layout div\").draggable({
  17.         revert:function() {
  18.             var a = $(\"#layout div\").offset().left;
  19.             var b = $(\"#layout\").width();
  20.             if (a >= b) {
  21.                 $(\"#layout\").text(\"恭喜您获得5000万美元大奖!\").css(\"color\",\"red\").fadeOut(200).fadeIn(500);
  22.                 return false;
  23.             }else{
  24.                 return true;
  25.             }
  26.         },
  27.         axis: \"x\", snap: \"#layout\", scroll: false}
  28.     );
  29.     $(\"#layout2 div\").click(function() {
  30.         $(this).animate({
  31.             width : \"+=20\",
  32.         }).animate({
  33.             width : \"-=50\",
  34.         });
  35.         if ($(this).width() <= 30) {
  36.             $(\"#layout2\").text(\"恭喜您获得5000万美元大奖!\").css(\"color\",\"red\").fadeOut(200).fadeIn(500);
  37.         }
  38.     });
  39. });
  40. </script>
  41. </head>
  42. <body>
  43. <div>说明:不支持IE6!</div>
  44. <p> </p>
  45. <p>效果一(拖拽灰条):</p>
  46. <div id=\"layout\">
  47.     <div></div>
  48.     请完全撕开查看中奖结果。
  49. </div>
  50. <p> </p>
  51. <p>效果二(点击灰条):</p>
  52. <div id=\"layout2\">
  53.     <div></div>
  54.     请完全撕开查看中奖结果。
  55. </div>
  56. </body>
  57. </html>


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29737856/viewspace-1220905/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-07-04

  • 博文量
    95
  • 访问量
    122213