테스트 사이트 - 개발 중인 베타 버전입니다

(소스)jqury 롤오버 버튼 쉽게 만들기

· 13년 전 · 4216 · 5
//제이쿼리 선언
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
 
//이미지 class="rollover" 주면 자동 롤오버 class="rollover active" 마우스 오버되어있을떄 효과
// 주의사항 이미지명 뒤에 _off,_on으로 구분 주어야함
<img src="image01_off.jpg" class="rollover" />
<img src="image02_off.jpg" class="rollover active" />
<img src="image03_off.jpg" class="rollover" />
<img src="image04_off.jpg" class="rollover" />
 
//스크립트는 하단에 호출 해주어야한다
<script type="text/javascript">
if ( $('img').hasClass('active') ){
$('img.active').attr('src', $('img.active').attr('src').split('_off.')[0] + '_on.' + $('img.active').attr('src').split('_off.')[1]);
}
$('img.rollover').mouseover(function(){
if ( !$(this).hasClass('active') ){
var image_name = $(this).attr('src').split('_off.')[0];
var image_type = $(this).attr('src').split('off.')[1];
$(this).attr('src', image_name + '_on.' + image_type);
}
}).mouseout(function(){
if ( !$(this).hasClass('active') ){
var image_name = $(this).attr('src').split('_on.')[0];
var image_type = $(this).attr('src').split('_on.')[1];
$(this).attr('src', image_name + '_off.' + image_type);
}
});
</script>
 
이렇게 하면 쉽게 롤오버 버튼을 제작할수있습니다~
알고계셧다면 죄송..
 

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 5개

ㄳㄳ
13년 전
감사합니다
적용해 보겠습니다.
감사합니다.
13년 전
오홍..감사합니다.

게시글 목록

번호 제목
12413
12412
12411
12410
12407
12406
12405
12404
12403
12402
12401
12400
12399
12398
12397
12396
12395
12394
12393
12392
12391
12390
12389
12388
12387