반응형
attr을 mouseenter/mouseleave/click으로 변경하기
var tabIdx = '';
$('.tab_wrap li').on({
mouseenter:function(){
$(this).children('img').attr('src', $(this).children('img').attr('src').replace('_off', '_on'))
},
mouseleave:function(){
$('.tab_wrap li').each(function(){
$(this).children('img').attr('src', $(this).children('img').attr('src').replace('_on', '_off'));
});
$('.tab_wrap li:eq('+tabIdx+')').children('img').attr('src', $('.li_wrap li:eq('+tabIdx+')').children('img').attr('src').replace('_off', '_on')) //cont가 열려있는 tab은 'on'
},
click: function(){
tabIdx = $(this).index();
$(this).children('img').attr('src', $(this).children('img').attr('src').replace('_off', '_on'));
$('.tabCont_wrap li').removeClass('active');
$('.tabCont_wrap li:eq('+tabIdx+')').addClass('active');
}
});
반응형
'퍼블리셔 > jquery' 카테고리의 다른 글
input[type="file] custom (0) | 2020.09.25 |
---|---|
input[type="text"] 숫자만 입력 (0) | 2020.04.06 |
animate 다중클릭/중복클릭/다클릭 방지 (0) | 2019.11.14 |
<a href="#id">로 이동 부드럽게 하기 (0) | 2019.11.12 |
:empty 사용하기 (0) | 2019.10.22 |