티스토리 뷰

1. 윈도 이벤트 - 역할

윈도 반응에 따른 이벤트


2. 윈도이벤트  - 정리

이벤트 이름

설명

ready

객체 준비 완료

load

윈도를 불러들일 때

unload

윈도를 닫을 때

resize

윈도 크기 변화가 있을 때

scroll

윈도 스크롤이 발생할 때

error

에러가 있을 


3. 윈도이벤트  - 예제1

◈ 코드


1
2
3
4
5
6
7
8
9
10
<script src="https://code.jquery.com/jquery-1.11.3.js" type="text/javascript"></script>
 
<script>
$(document).ready(function () 
{
    $(window).load(function(){
        alert("load 이벤트");
    });
});
</script>




 

◈ 결과화면





◈ 설명


처음 화면을 실행하면 위와 같은 alert 창이 발생합니다




4. 윈도이벤트  - 예제2

◈ 코드


1
2
3
4
5
6
7
8
9
10
<script src="https://code.jquery.com/jquery-1.11.3.js" type="text/javascript"></script>
 
<script>
$(document).ready(function () 
{
    $(window).scroll(function(){
        alert("scroll 이벤트");
    });
});
</script>





◈ 결과화면






◈ 설명


윈도우 스크롤이 움직일 때 마다 위와 같은 alert 창이 발생합니다





댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday