Jquery动态解绑,绑定Onclick (此处用的是span)

绑定:

    $("#sendMessage").on("click",function(){

        var mobilePhone =  $.trim($("#mobileNo").val());
        if (mobilePhone.length <= 0 || mobilePhone == 'undefined') {
            layer.alert("请输入手机号~", {icon: 2});
            return;
        }
        var phone_reg  = /(^13\d{9}$)|(^14)[5,7]\d{8}$|(^15[0,1,2,3,5,6,7,8,9]\d{8}$)|(^17)[6,7,8]\d{8}$|(^18\d{9}$)/g ;  
        if (!phone_reg.test(mobilePhone)) {
            layer.alert("手机格式不正确~", {icon: 2});
            return;
        }
        var picCaptcha = $("#picCaptcha").val();
        if (picCaptcha.length<=0 || picCaptcha == 'undefined') {
            layer.alert("请输入图片验证码~", {icon: 2});
            return;
        }
        var dataParam = {picCaptcha:picCaptcha,mobilePhone:mobilePhone};
        $.ajax({
            url : '/ajax/SMS/send.htm',
            type : "POST",
            data : dataParam,
            dataType : 'json',
            success : function(data) {
                //alert(data.status);
                if(data.status == 500){
                    layer.alert(data.message, {icon: 2});
                }else{
                    var obj =  $("#sendMessage");
                    setMessagetime(obj);
                    layer.alert("发送短信成功,请输入你收到的验证码", {icon: 2});
                    $("#sendMessage").off("click");
                }
            }
        });

    });


解绑:

$("#sendMessage").off("click");

你可能感兴趣的:(jquery)