当“重力形式”出现时触发 jquery输入按钮被点击
我更新了这个问题,因为这可能是由于重力形式阻止了一个简单函数的工作。我这么说的原因是因为我尝试了很多选项(下面列出)来触发 jQuery 函数,但没有一个在应该起作用的时候起作用。
我有一个简单的函数,低于它 100% 有效...
var $contactButton = $(".contact-slide a"),
$contactSlide = $("#horizon-slide");
function () {
$contactSlide.stop().css("top","0");
};
很简单,但是当我的提交按钮被重力点击时,我试图触发这个函数。
这是 WordPress 重力形式输入标记...
<input type="submit" id="gform_submit_button_1" class="button gform_button" value="Send" tabindex="7"></input>
这些是我尝试过的所有脚本,但没有一个运行该函数...
脚本一
$("input#gform_submit_button_1").on('click', function () {
$contactSlide.stop().css("top","0");
});
脚本二
$("input#gform_submit_button_1").click(function() {
$contactSlide.stop().css("top","0");
});
脚本三
$("input#gform_submit_button_1").focus(function () {
$contactSlide.stop().css("top","0");
});
< strong>脚本四
$("form#gform_1").submit(function(event) {
$contactSlide.stop().css("top","0");
});
我也尝试过......
return false;
以及
return true;
上面的所有脚本,但它们都没有返回该函数。如果我将脚本设置为返回 false,则表单不会提交,但如果我设置为返回 true,则表单会提交,但该函数不会运行。
为什么会发生这种情况,我以为这是基本的事情?
感谢您的任何帮助。
I've updated the question because it may because of gravity forms which is stopping a simple function from working. The reason I say this is because I've tried so many options (listed below) to trigger a jQuery function, and none of them work when they should.
I have a simple function below which 100% works...
var $contactButton = $(".contact-slide a"),
$contactSlide = $("#horizon-slide");
function () {
$contactSlide.stop().css("top","0");
};
Simple as it gets, but I'm trying to trigger this when my submit button gets clicked from a gravity from.
This is the wordpress gravity forms input markup...
<input type="submit" id="gform_submit_button_1" class="button gform_button" value="Send" tabindex="7"></input>
These are all the scripts below that I've tried, but none of them run the function...
Script One
$("input#gform_submit_button_1").on('click', function () {
$contactSlide.stop().css("top","0");
});
Script Two
$("input#gform_submit_button_1").click(function() {
$contactSlide.stop().css("top","0");
});
Script Three
$("input#gform_submit_button_1").focus(function () {
$contactSlide.stop().css("top","0");
});
Script Four
$("form#gform_1").submit(function(event) {
$contactSlide.stop().css("top","0");
});
I've also tried...
return false;
and
return true;
on all of the scripts above, but none of them return the function. If I set the scripts to return false then the form does not submit, but if I set to return true, then form submits but the function does not run.
Why is this happening, I thought this would be basic stuff?
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否想在提交表单时运行某些操作?如果您使用表单的 AJAX 提交方法,则可以使用 gform_confirmation_loaded 事件来提交表单后运行一些 JavaScript。
它将在每个表单提交上运行,因此要指定表单,请测试传递给事件处理程序的 form_id 参数。
Are you trying to have something run upon form submission? If you're using the AJAX submission method of the form you can use the gform_confirmation_loaded event to run some JavaScript after the form is submitted.
It will run on every form submission so to specify the form, test the form_id parameter passed to the event handler.
如果您有表单,您可以通过表单提交来控制它。
You can control it from the form submit if you have a form..
尝试一下:)
Give it a try :)