0
我有以下代碼,它可以很好地打開/關閉/切換一系列div。保持切換div通過在url中的錨點打開
$("a").click(function(){
var myelement = $(this).attr("href")
$(myelement).slideToggle("slow");
$(".toggle:visible").not(myelement).hide();
});
我想要的是,如果頁面刷新或保存在錨鏈接中,div仍然保持打開狀態。即。金融股利應保持開放,如果網址是:
http://mywebsite/page#finance
感謝
請按照以下這些線索檢測鏈接中的錨點:http://stackoverflow.com/questions/298503/how-can-you-check-for-a-hash-in-a-url-using-javascript和http://stackoverflow.com/questions/3552944/how-to-get-the-anchor-from-the-url-using-jquery你最初可以隱藏div(通過css),並且只在錨標籤是目前或反之亦然。 –