layer弹层content写错导致div复制了一次,导致id失效 $().val() 获取不到dispaly:none div里表单的值

错误之源:

$("a.consult").click(function () {
        lib_consult_html = $('#consult-html').html();  /*复制了一份div*/
        layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            shadeClose: true,
            content: lib_consult_html  /*这里写迷了吧*/
       });
    });

查看layer文档修改后:

$("a.consult").click(function () {
         layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            shadeClose: true,
            content: $('#consult-html')
        });
    }); 

 然后div里的提交事件就生效了:

 $('#model_click').click(function () {
        var phone = $('#z_phone').val();
        var budget = $('#z_budget').val();
        var data = $("#model_form").serializeArray();
        console.log(data);
        if (phone != "" && budget != "") {
            $.ajax({
                url: '/tools/submit_ajax.ashx?action=my_modelSend',
                dataType: "text",
                type: 'post',
                data: data,
                success: function (date) {
                    alert(date);
                    console.log(date);
                    document.getElementById("model_form").reset();
                }
            });
        } else {
            alert("联系电话和预算必填哦!!!");
        }
    });

posted @ 2018-11-26 23:00  大番薯没有心  阅读(214)  评论(0)    收藏  举报