흑횽DX

[JQuery] 웹표준/웹접근성 탭 스크립트

아래소스는 제가 만든 간단한 스크립트입니다.

a 엘리먼트를 클릭하면 발생하는 이벤트이죠.

물론 CSS에서도 처리할 부분이 있지만.. 

이와 같은 방법으로 하면 클릭및 포커스를 개별적으로 관리할 수 있습니다.

또한 DOM을 독립적으로 관리할 수 있겠죠 ^^

완벽한 소스는 아니니. 참고만 하세염 ^^

 

<script>

$( ".wrap_body .inner .contents .wrap_hitEtc .tit  li > a " ).click(function() {

var forNum = $(".wrap_body .inner .contents .wrap_hitEtc .tit").find('li').length;

var clickNum = $(this).attr('id').replace(/[^0-9]/g,"");

mainDsplayCss(forNum, clickNum);

 

});

 

$( ".wrap_body .inner .contents .wrap_hitEtc .tit  li > a " ).focus(function() {

var forNum = $(".wrap_body .inner .contents .wrap_hitEtc .tit").find('li').length;

var clickNum = $(this).attr('id').replace(/[^0-9]/g,"");

mainDsplayCss(forNum, clickNum);

});

 

function mainDsplayCss(forNum, clickNum){

for(var i = 1; i <= forNum; i++){

if(i == clickNum){

if(i != 1){

$( ".wrap_body .inner .contents .wrap_hitEtc .tit li:first-child a").css("background","#fff");

$( ".wrap_body .inner .contents .wrap_hitEtc .tit li:first-child a").css("color","#000");

}

if(i == 1){

$( ".wrap_body .inner .contents .wrap_hitEtc .tit li:first-child a").css("background","#ff4800");

$( ".wrap_body .inner .contents .wrap_hitEtc .tit li:first-child a").css("color","#fff");

}

$( "#hitEtc_contents"+i ).css("display","block");

}else{

$( "#hitEtc_contents"+i ).css("display","none");

}

}

}

</script>

댓글 2개

참고만 할께요.....ㅎㅎ
^^ 참고만 할수 있는 소스입니다.
댓글을 작성하시려면 로그인이 필요합니다.

오픈소스

75건
+
제목 글쓴이 날짜 조회
23-08-12 조회 730
22-04-25 조회 1,204
18-11-27 조회 2,387
18-09-07 조회 1,967
17-05-30 조회 4,372
17-05-29 조회 3,129
16-11-25 조회 3,963
16-10-24 조회 2,558
16-10-12 조회 2,642
16-10-11 조회 3,298
16-10-10 조회 4,152
16-09-30 조회 2,687
16-09-30 조회 2,728
16-09-29 조회 2,930
16-09-27 조회 2,470
16-09-27 조회 5,159
16-09-26 조회 3,145
16-09-23 조회 2,657
16-04-01 조회 2,650
16-02-12 조회 2,549
16-02-12 조회 3,524
16-02-12 조회 3,405
16-02-10 조회 2,553
16-02-09 조회 5,302
16-02-08 조회 3,053
16-02-07 조회 3,656
16-02-07 조회 3,066
16-02-05 조회 2,885
16-02-05 조회 4,565
16-02-03 조회 3,324