gpt4 book ai didi

javascript - 如何使用 javascript 加载表单?

转载 作者:行者123 更新时间:2023-11-28 00:21:21 26 4
gpt4 key购买 nike

当我使用这个脚本时

<form id="mktoForm_1740"></form>
<script>MktoForms2.loadForm("//app-e.example.com", "517-ITT-285", 1740);</script>

表单将正常加载。但下面的脚本没有加载表单。我认为问题与 javascript 有关。

<script>MktoForms2.loadForm("//app-example.com", "517-ITT-285", 1740, function(form){
//Add an onSuccess handler
form.onSuccess(function(values, followUpUrl){
//get the form's jQuery element and hide it
form.getFormElem().hide();
document.getElementById('confirmform').style.visibility = 'visible';
//return false to prevent the submission handler from taking the lead to the follow up url.
return false;
});
});
</script>
<div id="confirmform" style="visibility:hidden;margin-top: 35px;"><p><strong>Thank you for registering. You will receive a confirmation by email in a minute.</strong></p></div>

如何解决这个问题......

最佳答案

使用$(document).ready(function(){});

试试这个

<script>
$(document).ready(function() {
MktoForms2.loadForm("//app-example.com", "517-ITT-285", 1740, function(form) {
//Add an onSuccess handler
form.onSuccess(function(values, followUpUrl) {
//get the form's jQuery element and hide it
form.getFormElem().hide();
document.getElementById('confirmform').style.visibility = 'visible';
//return false to prevent the submission handler from taking the lead to the follow up url.
return false;
});
});
});
</script>
<div id="confirmform" style="visibility:hidden;margin-top: 35px;">
<p><strong>Thank you for registering. You will receive a confirmation by email in a minute.</strong></p>
</div>

关于javascript - 如何使用 javascript 加载表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30000375/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com