모바일 네이게이션 바 질문입니다. (2)
본문
해당 버튼을 눌러 페이지 이동했을때 폰트 컬러를 바꾸고 싶은데
어떤 소스가 있을까요?
<div class="section2 cboth">
<div class="line"></div>
<ul class="cboth">
<li><a href="/m/product_list.html?type=Y&xcode=001">카테고리</a></li>
<li><a href="/m/product_list.html?type=Y&xcode=003">베스트</a></li>
<li><a href="/m/product_list.html?type=Y&xcode=006">의류</a></li>
<li><a href="/m/product_list.html?type=Y&xcode=007">헬스/뷰티</a></li>
<li><a href="/m/product_list.html?type=Y&xcode=008">생활/욕실</a></li>
</ul>
<div class="line1"></div>
</div>
답변 3
<style>
.selected { color:red } // red 로 변경
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function () {
$("li").each(function () {
$(this).click(function () {
$(this).addClass("selected"); // selected 클래스 적용 ->red 로 변경
$(this).siblings().removeClass("selected"); // siblings() ->형제 요소중, removeClass나머 지는 클래스 적용해제
});
});
});
</script>
<style>
li.active a{color : blue;}
</style>
<div class="section2 cboth">
<div class="line"></div>
<ul class="cboth">
<li <?php if($xcode == '001'){?> class="active" <?php }?>><a href="/m/product_list.html?type=Y&xcode=001">카테고리</a></li>
<li <?php if($xcode == '002'){?> class="active" <?php }?>><a href="/m/product_list.html?type=Y&xcode=003">베스트</a></li>
<li <?php if($xcode == '003'){?> class="active" <?php }?>><a href="/m/product_list.html?type=Y&xcode=006">의류</a></li>
<li <?php if($xcode == '004'){?> class="active" <?php }?>><a href="/m/product_list.html?type=Y&xcode=007">헬스/뷰티</a></li>
<li <?php if($xcode == '005'){?> class="active" <?php }?>><a href="/m/product_list.html?type=Y&xcode=008">생활/욕실</a></li>
</ul>
<div class="line1"></div>
</div>
<script src="http://code.jquery.com/jquery-latest.js"></script>
온라인 연결 되어야 합니다