函数作用域

函数作用域,html()方法加载的jquery对象在函数体内,内部元素要想再次加上
事件需要在函数体内增加

    ;
    $(function() {
    //用户添加
    var ctrUserData = null;
    /* 弹出层的相关定义 */
    //点击添加
    $(".add").on("click", function() {
        if(null == ctrUserData) {
            ctrUserData = $("#iframeDiv").html();
        }
        $("#iframeDiv").empty();
    //函数作用域,HTML方法加载的jquery对象在函数体内,内部元素要想再次加上
    事件需要在函数体内增加
        $("#iframeDiv").html(ctrUserData);
        $("#add_content").css("display", 'block');
        //页面层-自定义
        layer.open({
            id: "addlayer",
            type: 1,
            title: false,
            closeBtn: 0,
            area: "811px",
            shadeClose: false,
            skin: 'yourclass',
            content: $("#iframeDiv"), //iframe的url,no代表不显示滚动条
        });

        //点击关闭
        $('.close').on("click", function() {
            $("#iframeDiv").css("display", 'none');
            $(".ac").each(function() {
                $(".ac").css("display", 'none');
            })
            layer.closeAll('page');

        })
        //点击完成
        $('.finish').on("click", function() {
            $("#iframeDiv").css("display", 'none');
            $(".ac").each(function() {
                $(".ac").css("display", 'none');
            })
            layer.closeAll('page');

        })
    //点击下一步
        $(".first_step").on("click", function() {
            $(".add_content").hide();
            $(".add_content2").show();
            $(".add_content3").hide();
            $(".add_content4").hide();
            //        var cont = $(".input1").serialize();
            //        $.ajax({
            //            url: '',
            //            type: 'post',
            //            contentType: "application/x-www-form-urlencoded", //post只能写urlencoded,json不能被识别
            //            dataType: 'json',
            //            data: cont,
            //            success: function(data) {
            //                if(data.ret == true) {
            //                    $(".add_content").hide();
            //                    $(".add_content2").show();
            //                    $(".add_content3").hide();
            //                    $(".add_content4").hide();
            //                }
            //            }
            //        });
            //
        });
        $(".second_step").on("click", function() {
            $(".add_content").hide();
            $(".add_content2").hide();
            $(".add_content3").show();
            $(".add_content4").hide();
        });
        $(".second_step_up").on("click", function() {
            $(".add_content").show();
            $(".add_content2").hide();
            $(".add_content3").hide();
            $(".add_content4").hide();
        });
        $(".third_step").on("click", function() {
            $(".add_content").hide();
            $(".add_content2").hide();
            $(".add_content3").hide();
            $(".add_content4").show();
        });
        $(".third_step_up").on("click", function() {
            $(".add_content").hide();
            $(".add_content2").show();
            $(".add_content3").hide();
            $(".add_content4").hide();
        });
        $(".four_step_up").on("click", function() {
            $(".add_content").hide();
            $(".add_content2").hide();
            $(".add_content3").show();
            $(".add_content4").hide();
        });

        //角色添加

        $("#first_step").on("click", function() {
            $("#add_content3").show();
            $("#add_content").hide();
            $("#add_content4").hide();
        })
        $("#second_step").on("click", function() {
            $("#add_content4").show();
            $("#add_content3").hide();
            $("#add_content").hide();

        })
        $("#second_step_up").on("click", function() {
            $("#add_content").show();
            $("#add_content3").hide();
            $("#add_content4").hide();
        });
        $("#third_step_up").on("click", function() {
            $("#add_content3").show();
            $("#add_content").hide();
            $("#add_content4").hide();
        });

    }); //add on over

    });

 

posted @ 2018-01-30 14:24  我哼哼  阅读(143)  评论(0编辑  收藏  举报