Jquery,点击,隐藏div并替换隐藏的div

Ada*_*m G 0 html css jquery

我不确定我是否正确行事.或者,如果这是最好的方法.

基本上我想要的是:点击#button_3它,它隐藏我的#contentdiv并显示#formdiv.我的表格div设置为display:none.

干杯!

$("#button_3").on("click", function(e){
        $("#content").hide(function(this)
        $("#form").show();
        )};
    });
Run Code Online (Sandbox Code Playgroud)

Ami*_*oki 5

这样做:

$("#button_3").on("click", function(e){
     $("#content").hide();
     $("#form").show();
});
Run Code Online (Sandbox Code Playgroud)

如果你想要性能,那么使用bind()而不是on()因为它是最快的.

请参阅jsperf