마우스 오버 적용하는 방법부탁드려요.
본문
<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>