2013-05-19 99 views
-1

我打電話給下面的代碼加載到div的HTML。jquery加載html和隱藏並顯示

 $('#strap').click(function(e) { 
     e.preventDefault(); 
     $('#collection_content').load('collection_sub.html'); 

    }); 

我呼籲這使它消失

$('#collection_content').hide(); 

但是當我嘗試再次加載相同的HTML文件,它不會顯示任何東西..就是它,因爲它是隱藏?我應該如何讓它再次出現?現在,'collection_sub.html'是靜態的,但它將被替換爲一個PHP動態頁面,所以我想重新加載它..有沒有辦法做到這一點?

謝謝。

回答

1

要使它再次出現,只是調用.show()

$('#collection_content').show().load('collection_sub.html'); 

如果元素已經可見,.show()不會有任何影響。

+0

很好。非常感謝。 – user826323

0

.loadhide.show

在這裏,如果你想隱藏後,加載ü需要UE像這樣ü要點擊ID =帶那麼它會加載一個頁面collection_sub.html入格的collection_content.so。如果你想再次點擊#strap時顯示它,你想用它像波紋管

 $('#strap').click(function(e) { 
      e.preventDefault(); 
      $('#collection_content').load('collection_sub.html',function(){ 
    $('#collection_content').hide(); 

    $('#strap').click(function(e) { 

    $('#collection_content').show(); 

     }); 

    }); 

}); 
+0

它是一個問題@undefined?你能說清楚嗎? – underscore

+0

是的,當單擊'#strap'元素時,會調用幾個處理程序。 – undefined