我的代码有什么问题吗?
单击按钮后,我想隐藏并显示一个带有另一个结果的 div
。
这种情况正在发生,但没有运行提交代码。字段值未传播。
$(document).ready(function(){
$('#conteudo').hide();
$('#button').click(function(event){
$('form#form1').submit(function(event){
$("#form").hide("slow");
$("#conteudo").show("slow");
event.preventDefault();
});
});
$('#mostrar').click(function(event){
event.preventDefault();
$("#form").show("show");
$("#conteudo").hide("show");
});
});
最佳答案
http://api.jquery.com/submit/说:
...so we can cancel the submit action by calling .preventDefault() on the event object or by returning false from our handler. ...
您应该删除 PreventDefault()
关于javascript - 提交后隐藏div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20748363/