답변 3개
채택된 답변
+20 포인트
마르스컴퍼니
8년 전
Copy
$(function(){
var current = window.location.pathname;
$('li a').each(function(){
var link = '/' + $(this).attr('href');
if (current == link){
$(this).parent().addClass('active');
}
});
});
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
우리는노예가아니다
8년 전
혹시 원하시는게 이런 거였나요? ㅎㅎ
테스트 링크입니다.
http://www.koreacraft.kr/test1.php
Copy
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("li a").on("mousedown",function(){
$("li").addClass("active");
});
});
</script>
<style>
.active { list-style:none; }
</style>
<body>
<li>
<a href="#">aaa </a>
</li>
</body>
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
8년 전
링크를 누르면 다시 페이지로 전환되는데... active class 를 왜 넣어야 하는지...
이미 떠난 여인은 붙잡는것은 아닙니다.
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인