php 砸金蛋抽奖,jQuery抽奖砸金蛋代码

特效描述:jQuery抽奖 砸金蛋代码。请在PHP环境下砸蛋

代码结构

1. 引入JS

2. HTML代码

jquery+php 请在服务器环境运行才能看到敲蛋后的效果。

锤子

1 2 3

function eggClick(obj) {

var _this = obj;

$.getJSON("data.php",function(res){

if(_this.hasClass("curr")){

alert("蛋都碎了,别砸了!刷新再来.");

return false;

}

//_this.unbind('click');

$(".hammer").css({"top":_this.position().top-55,"left":_this.position().left+185});

$(".hammer").animate({

"top":_this.position().top-25,

"left":_this.position().left+125

},30,function(){

_this.addClass("curr"); //蛋碎效果

_this.find("sup").show(); //金花四溅

$(".hammer").hide();

$('.resultTip').css({display:'block',top:'100px',left:_this.position().left+45,opacity:0}).animate({top: '50px',opacity:1},300,function(){

if(res.msg==1){

$("#result").html("恭喜,您中得"+res.prize+"!");

}else{

$("#result").html("很遗憾,您没能中奖!");

}

});

}

);

});

}

$(".eggList li").click(function() {

$(this).children("span").hide();

eggClick($(this));

});

$(".eggList li").hover(function() {

var posL = $(this).position().left + $(this).width();

$("#hammer").show().css('left', posL);

})

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值