我的网站上有一些表单,我使用下面的 jquery 脚本在有人点击它时隐藏提交按钮,这样他们在等待表单提交时就不会多次点击它(该代码还将其替换为一些“请稍候”文本)。它在桌面上完美运行,但在移动设备上根本无法运行。有人可以建议为什么会发生这种情况吗?
<script>
jQuery(document).ready(function() {
jQuery('#gform_next_button_5_85', this).click(function() {
jQuery('#gform_next_button_5_85').css('display','none');
jQuery('#gform_previous_button_5_85').css('display','none');
jQuery('.pleasewait').css('display','block');
});
jQuery('#gform_submit_button_5', this).click(function() {
jQuery('#gform_submit_button_5').css('display','none');
jQuery('#gform_previous_button_5').css('display','none');
jQuery('.pleasewait2').css('display','block');
});
});
</script>
最佳答案
只需替换您拥有类似内容的所有代码:
jQuery('#gform_next_button_5_85', this).click(function() { /*code*/ });
像这样:
jQuery('html').on('click touchend', '#gfrom_next_button_5_85', function() { /*code*/ });
我认为你在 iOS 设备上有问题,所以你必须添加 'touchend' 事件。
关于jquery - 为什么这个 jquery 脚本不能在移动设备上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46717887/