반응형
#스크립트로 호버된 이미지 변경하기
$(function(){
var list = $(".post-row .con_bt")
list.mouseover(function(){
index = $(this).index();
list.find(".real_i").attr("src",$(this).find(".real_i").attr("src").replace("on","off"));
$(this).find(".real_i").attr("src",$(this).find(".real_i").attr("src").replace("off","on"));
});
list.mouseleave(function(){
index = $(this).index();
list.find(".real_i").attr("src",$(this).find(".real_i").attr("src").replace("on","off"));
});
});
+위의 식을 함수로 바꿔서 사용
function on_img(obj){
var o_img = $(obj).siblings().find('img').attr('src');
var real_img = o_img.replace('_off','_on');
$(obj).siblings().find('img').attr('src',real_img);
}
function off_img(obj){
var o_img = $(obj).siblings().find('img').attr('src');
var real_img = o_img.replace('_on','_off');
$(obj).siblings().find('img').attr('src',real_img);
}
728x90
반응형
'JS & jQuery' 카테고리의 다른 글
tab안의 map 태그 안먹을경우 (0) | 2022.02.07 |
---|---|
원클릭과 더블클릭 액션 (0) | 2022.01.24 |
라디오 버튼 선택시 활성화&비활성화 (0) | 2022.01.24 |
아코디언 메뉴 (0) | 2022.01.17 |
이미지맵 (0) | 2022.01.17 |