링크 이동 문제 조언 좀 부탁드리겠습니다ㅠ 채택완료
<!-- 탭 메뉴 -->
<div class="liveEdtap">
<ul>
<li><a href="#1" data="1">업체</a></li>
<li><a href="#2" data="2">교육</a></li>
<li><a href="#3" data="3">신청서</a></li>
</ul>
</div>
<!-- 신청서 폼 -->
<div class="liveEdtapCon" id="3">
<?php include_once(G5_BBS_PATH."/register2.php");?>
</div>
<!-- 동작 -->
<script>
$(document).ready(function(){
$(".liveEdtapCon").hide();
$(".active").show();
$("div.liveEdtap > ul > li > a").click(function(){
$(".liveEdtap > ul > li").removeClass("active");
$(".liveEdtapCon").removeClass("active");
$(this).parent().addClass("active");
$("#"+$(this).attr("data")).addClass("active");
$(".liveEdtapCon").hide();
$(".active").show();
return false;
});
});
</script>
이렇게 있는데
해당문서 파일이 homepage.com/mypage.php 라고하면
homepage.com/mypage.php#3 URL을 직접 입력 하면 신청서 탭에 가고싶은데
그게안되네요 ㅠㅠ
탭을 클릭해도 #은 안뜨고 homepage.com/mypage.php URL만 떠요..ㅠ
조언좀 부탁드릴게요
답변 1개
http://benalman.com/code/projects/jquery-hashchange/examples/hashchange/#test4
jquery hashchange event 플러그인 이용해보세요.
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
$(function(){
// Bind an event to window.onhashchange that, when the hash changes, gets the
// hash and adds the class "selected" to any matching nav link.
$(window).hashchange( function(){
var hash = location.hash;
// Set the page title based on the hash.
document.title = 'The hash is ' + ( hash.replace( /^#/, '' ) || 'blank' ) + '.';
// Iterate over all nav links, setting the "selected" class as-appropriate.
$('#liveEdtap a').each(function(){
var that = $(this);
that[ that.attr( 'href' ) === hash ? 'addClass' : 'removeClass' ]( 'selected' );
});
})
// Since the event is only triggered when the hash changes, we need to trigger
// the event now, to handle the hash the page may have loaded with.
$(window).hashchange();
});