javascript - 提交后隐藏div

标签 javascript jquery

我的代码有什么问题吗?

单击按钮后,我想隐藏并显示一个带有另一个结果的 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/

相关文章:

javascript - i18n JavaScript 设置

javascript - 将里程表绑定(bind)到 Datalist 和 gridview

javascript - 在移动或桌面视口(viewport)中时 jQuery 触发函数

JQuery 使用 .each() 延迟

javascript - 我如何计算数组的模式并忽略数据

javascript - 常量的Polyfill(有点)?

javascript - 使用 Require JS 加载 js 文件

javascript - 如何从 UTC 字符串中获取小时和分钟?

javascript - 是否有一种 jQuery 方法可以仅迭代对象自己的属性?

javascript - 当提交按钮在表单之外时,如何使用 Bootstrap 3 表单验证?