원

마우스를 이미지 위에 올렸을때 이미지 흔들기

· 2010-06-30 (수) 11:22:56 · 3122

 

<style>
.shakeimage
{
position:relative
}
</style>

<script>
var rector=3
var stopit=0
var a=1

function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}

function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}
function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}
</script>

그 다음 스크립트는 넣었으면 <body></body>안에 있는 이미지중 스크립트를 적용시킬 이미지를 찾아서 이미지 태그안에 이렇게 추가합니다. <class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this)">

[이 게시물은 관리자님에 의해 2011-10-31 16:57:14 JavaScript에서 이동 됨]
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
12-01-11 조회 2,775
12-01-11 조회 1.2만
12-01-10 조회 2,871
12-01-08 조회 3,460
12-01-05 조회 5,349
11-12-29 조회 3,068
11-12-27 조회 2,858
11-12-25 조회 3,038
11-12-22 조회 3,475
11-12-14 조회 2,936
11-12-12 조회 3,574
11-11-28 조회 3,394
10-10-19 조회 2,853
08-09-05 조회 3,770
08-09-05 조회 3,589
08-06-14 조회 3,328
08-04-22 조회 3,611
08-04-17 조회 3,615
07-10-03 조회 4,225
07-10-03 조회 3,620
07-10-03 조회 7,303
07-10-03 조회 4,580
07-10-03 조회 3,284
07-10-03 조회 2,873
07-10-02 조회 3,588
07-10-02 조회 3,114
07-09-27 조회 5,036
07-09-27 조회 3,861
06-09-26 조회 3,524
06-09-26 조회 4,746
06-09-22 조회 3,919
06-09-22 조회 3,537
06-09-22 조회 4,288
06-09-21 조회 4,216
06-08-18 조회 3,709
05-11-30 조회 4,752
05-07-15 조회 4,608
05-03-23 조회 4,662
05-03-14 조회 3,331
05-03-13 조회 2,705
04-08-05 조회 5,781