마우스 오버 적용하는 방법부탁드려요.

마우스 오버 적용하는 방법부탁드려요.

QA

마우스 오버 적용하는 방법부탁드려요.

답변 2

본문

<script type="text/javascript"> 

$(function() { 

$("#lnb_sub_sup_menu li a img").hover(function(){ 

$(this).attr("src", $(this).attr("src").replace("_off.gif", "_on.gif")); 

}, function(){ 

$(this).attr("src", $(this).attr("src").replace("_on.gif", "_off.gif")); 

}); 

});

</script> 

 

<a href="#"><img src="img/abc01_on.gif" class="image_rollover" /></a>

 

이렇게 소스를 짜보았는데

on 이미지에서 off으로 넘어가지지가 않네용;;

이 질문에 댓글 쓰기 :

답변 2

<a href="#"><img src="img/abc01_on.gif" id='menu_01' class="image_rollover" /></a>  

 

$('img[id^=menu_]').mouseover(function(){

var num = $(this).attr("id").split('_');

$(this).attr("src", "img/abc"+num[1]+"_on.gif");

}).mouseout(function(){

var num = $(this).attr("id").split('_');

$(this).attr("src", "img/abc"+num[1]+"_off.gif");

});

 

요렇게 해보세요

<script type="text/javascript"> 

$(function() { 

$("#lnb_sub_sup_menu li a img").hover(function(){ 

$(this).attr("src", $(this).attr("src").replace("_on.gif", "_off.gif"));  

}, function(){ 

$(this).attr("src", $(this).attr("src").replace("_off.gif", "_on.gif")); 

}); 

});

</script> 

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 130
© SIRSOFT
현재 페이지 제일 처음으로