[英]Anchor Link - Open accordion on other site
我有一個手風琴網站。 現在,當我在鏈接上單擊我的起始站點時,該鏈接是指向具有錨點的另一個站點的鏈接,我想打開此特定的手風琴。 我解釋一下工作流程:
/news/#example1
正如Mathias所說,您必須從URL中獲取哈希值。 但是,如果您已經為ID為“ example1”的元素設置了手風琴jquery插件,則必須在URL上的哈希值觸發該元素。
例:
如果html是:
<div id="example1"> <div class="accordion-header">Some title here for the content</div> <div class="accordion-content">The actual content of the accordion</div> </div>
然后,您必須這樣做:
var hash = window.location.hash;
if(hash == "#example1")
$('#example1').find('.accordion-header').trigger('click');
如果每個新聞內容都有自己的ID,則可以執行以下操作:
var hash = window.location.hash;
$(hash).find('.accordion-header').trigger('click');
li
?) var hash = window.location.hash; $( '#' +哈希).show();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.