我想在按下提交按钮后显示 div
I want to show a div after pressing on submit button
我需要一些帮助
您在下面一行中看到的 "close modal" 按钮在加载时隐藏,因为我想强制用户在访问内容之前写下他们的姓名和电子邮件。
<div class="mc-closeModal" data-action="close-mc-modal" data-dojo-attach-point="modalClose" style="">close</div>
我现在要做的是在人们输入姓名和电子邮件并按下 "Subscribe" 按钮后让它再次出现。
我已经在控制台中尝试了下面的这段代码并且它有效。它提交详细信息并使 "close" 按钮再次出现。
$(document).ready(function() {
$('iframe').contents().find('input.button').click() //this line targets the submit button "Subscribe"
$("#PopupSignupForm_0 > div.mc-modal > div.mc-closeModal").show() //this line makes the "close" button appear again
});
问题是当我将它添加到网站时它不起作用。
我想要的很简单
当这个事件发生时
$('iframe').contents().find('input.button').click()
我要执行此操作
$("#PopupSignupForm_0 > div.mc-modal > div.mc-closeModal").show()
你的代码就是一条接一条的两条语句。您实际上并没有将任何内容绑定到点击事件。如果你想使用 jquery 的点击,你可以这样做:
$('iframe').contents().find('input.button').click(function() {
$("#PopupSignupForm_0 > div.mc-modal > div.mc-closeModal").show()
});
但是你不知道用户是否真的填写了表格。相反,你可以
试试这个:
$('#content__formFields').submit(function() {
var isValid = true;
// Check if empty of not
$(this).find('input[type!="hidden"]').each(function() {
if (!$(this).val()) {
isValid = false;
//change the element's css here so user knows whats missing
}
});
if (isValid)
$("#PopupSignupForm_0 > div.mc-modal > div.mc-closeModal").show()
return isValid
});
我需要一些帮助
您在下面一行中看到的 "close modal" 按钮在加载时隐藏,因为我想强制用户在访问内容之前写下他们的姓名和电子邮件。
<div class="mc-closeModal" data-action="close-mc-modal" data-dojo-attach-point="modalClose" style="">close</div>
我现在要做的是在人们输入姓名和电子邮件并按下 "Subscribe" 按钮后让它再次出现。
我已经在控制台中尝试了下面的这段代码并且它有效。它提交详细信息并使 "close" 按钮再次出现。
$(document).ready(function() {
$('iframe').contents().find('input.button').click() //this line targets the submit button "Subscribe"
$("#PopupSignupForm_0 > div.mc-modal > div.mc-closeModal").show() //this line makes the "close" button appear again
});
问题是当我将它添加到网站时它不起作用。
我想要的很简单
当这个事件发生时
$('iframe').contents().find('input.button').click()
我要执行此操作
$("#PopupSignupForm_0 > div.mc-modal > div.mc-closeModal").show()
你的代码就是一条接一条的两条语句。您实际上并没有将任何内容绑定到点击事件。如果你想使用 jquery 的点击,你可以这样做:
$('iframe').contents().find('input.button').click(function() {
$("#PopupSignupForm_0 > div.mc-modal > div.mc-closeModal").show()
});
但是你不知道用户是否真的填写了表格。相反,你可以 试试这个:
$('#content__formFields').submit(function() {
var isValid = true;
// Check if empty of not
$(this).find('input[type!="hidden"]').each(function() {
if (!$(this).val()) {
isValid = false;
//change the element's css here so user knows whats missing
}
});
if (isValid)
$("#PopupSignupForm_0 > div.mc-modal > div.mc-closeModal").show()
return isValid
});