2010-03-23 81 views
0

如何使用jQuery隐藏#changes-saved代码?jQuery显示问题?

例如,假设用户点击提交按钮,然后离开当前网页,然后返回到网页,并且#changes-saved不再显示,直到再次单击提交按钮时显示代码。

这里是jQuery代码。

$(function() { 
    $('#changes-saved').hide(); 
    $(".save-button").click(function() { 
     $.post($("#contact-form").attr("action"), $("#contact-form").serialize(), function(html) { 
      $("div.contact-info-form").html(html); 
      $('#changes-saved').append('<li>Changes saved!</li>').show().pause(1000).hide(); 
     }); 
     return false; // Prevent normal submit. 
    }); 
}); 

回答

0

在页面加载保持在div隐藏...

<div id = 'changes-saved' style='display:none'> 
    some stuff 
</div> 

在按钮单击更改div的CSS像...

$('#changes-saved').css('display','block'); 

希望这有助于..欢呼声.. 。!