错误之源:
$("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 /*这里写迷了吧*/ }); });
![点击并拖拽以移动](https://i-blog.csdnimg.cn/blog_migrate/d949ecfeb5f7a21a598742753ee2a1d8.png)
查看layer文档修改后:
$("a.consult").click(function () {
layer.open({
type: 1, title: false, closeBtn: 0, shadeClose: true, content: $('#consult-html') }); });
![点击并拖拽以移动](https://i-blog.csdnimg.cn/blog_migrate/d949ecfeb5f7a21a598742753ee2a1d8.png)
然后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("联系电话和预算必填哦!!!"); } });
![点击并拖拽以移动](https://i-blog.csdnimg.cn/blog_migrate/d949ecfeb5f7a21a598742753ee2a1d8.png)