내 웹 사이트에 좋은 타사 아코디언 (참조 URL : http://www.switchroyale.com/vallenato/)을 통합 했으므로 기본적으로 앵커 URL로 h1 ID
을 표시 할 수 없습니다.브라우저의 주소 표시 줄에 앵커 URL로 아코디언의 제목 ID를 추가하는 방법은 무엇입니까?
을 :
<body>
<div id="accordion-container">
<h1 class="accordion-header" id="tab1">What is it?</h1>
<div class="accordion-content">
<p>Some texts goes here</p>
</div>
<h1 class="accordion-header" id="tab2">Download</h1>
<div class="accordion-content">
<p>Some other texts goes here</p>
</div>
</div>
</body>
를 h1 ID
(여기서 "tab1"
와 "tab2"
결합하는 방법이있다 :
/*!
* Vallenato 1.0
* A Simple JQuery Accordion
*
* Designed by Switchroyale
*
* Use Vallenato for whatever you want, enjoy!
*/
jQuery(document).ready(function($)
{
//Add Inactive Class To All Accordion Headers
$('.accordion-header').toggleClass('inactive-header');
//Set The Accordion Content Width
var contentwidth = $('.accordion-header').width();
$('.accordion-content').css({'width' : contentwidth });
//Open The First Accordion Section When Page Loads
$('.accordion-header').first().toggleClass('active-header').toggleClass('inactive-header');
$('.accordion-content').first().slideDown().toggleClass('open-content');
// The Accordion Effect
$('.accordion-header').click(function() {
if($(this).is('.inactive-header')) {
$('.active-header').toggleClass('active-header').toggleClass('inactive-header').next().slideToggle().toggleClass('open-content');
$(this).toggleClass('active-header').toggleClass('inactive-header');
$(this).next().slideToggle().toggleClass('open-content');
}
else {
$(this).toggleClass('active-header').toggleClass('inactive-header');
$(this).next().slideToggle().toggleClass('open-content');
}
});
return false;
});
및 html
코드의 예는 다음과 같다 위의 html
코드에서 h1 IDs
이고 클릭 기능이 js
코드이므로 아코디언의 제목 ID가 검색 주소창에 앵커 URL로 추가됩니다. 다음 예제와 같이 관련 탭을 열려면 제목을 클릭 할 때마다 웹 브라우저에서?
http://www.somesite.com/somepage.html#tab1
http://www.somesite.com/somepage.html#tab2
감사
,
왜해야합니까 (www.somesite.com/somepage.html#tab1)? 설명 할 수 있니? 어떤 탭을 클릭했는지 기억하고 있습니까, 아니면 헤더를 클릭했을 때 다른 페이지로 이동하고 싶습니까? – madi
What is it?
과 같이하면 www.somesite.com/somepage.html#tab1이 표시됩니다. – Manoj@madi 각 탭마다 고유 한 URL을 갖고 싶습니다. –