모바일 네이게이션 바 질문입니다. (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>
답변에 대한 댓글 2개
댓글을 작성하려면 로그인이 필요합니다.
<script src="http://code.jquery.com/jquery-latest.js"></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>
답변에 대한 댓글 3개
오류가 나네요.. 왜그럴까요? ㅜㅜ
<style>
=>active 라는 클래스의 a태그에는 blue 글자색상을 줍니다.
<li <?php if($xcode == '001'){?> class="active" <?php }?>>
=> $xcode의 변수값이 001 이라면 active라는 클래스를 줍니다.
결과
=> 현제 페이지의 $xcode값(활성화된 값이겠죠)에 따라 blue 색상이 들어갑니다.
복붙하시면 안될수도 있고 제가 설명드린것을 참조하여서 소스를 수정해보세요
<?php if($xcode == '002'){?> class="active" <?php }?>
저 문장을 밖으로 뺐다가 넣었다가 다해봤는데도 잘 안되네요..ㅠㅠ 능력이 부족한 탓입니다. ㅠㅠ
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인