gpt4 book ai didi

JavaScript 阻止提交按钮工作

转载 作者:行者123 更新时间:2023-12-03 04:40:14 26 4
gpt4 key购买 nike

我有一个 js 充当“淡入淡出”页面转换:

jQuery('body').css('display','none');

jQuery(document).ready(function() {
jQuery('body').fadeIn();
jQuery('a').on('click',function(event){
var thetarget = this.getAttribute('target')

if (thetarget !="_blank" ) {
var thehref = this.getAttribute('href')

event.preventDefault();
console.log(thehref)
if(thehref){
console.log('not null')
jQuery('body').fadeOut(function(){
window.location = thehref
});
}
}
});
});

setTimeout(function(){
jQuery('body').fadeIn();
},1000)

我有这个表格:

<form id = "create_faculty_formcontainer" action = "" method = "post">
<input type = "text" name = "fac_idnumber" placeholder="ID Number" required/><br/><br/>
<input type = "text" name = "fac_firstname" placeholder="First Name" required/><br/><br/>
<input type = "text" name = "fac_lastname" placeholder="Last Name" required/><br/><br/>

<input type = "password" id = "password_fac" name = "fac_password" placeholder="Password" required/>

<br/>

<input type = "submit" name = "fac_submit" value = " sign up ">
</form>

每当我点击提交按钮时,什么也没有发生。所以我尝试删除我的 JavaScript 并且按钮起作用了。 js 一定是导致提交按钮不起作用,而我实际上无法弄清楚它是什么或如何修复它。关于如何保留 javascript 并使提交按钮也正常工作有什么想法吗?

最佳答案

我已经弄清楚了。删除event.preventDefault();就可以解决这个问题。感谢科格鲁

关于JavaScript 阻止提交按钮工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43123723/

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