JQuery

[Event] JQ - load() 메서드 - JQ 3.0 폐기완료. / 요소 로드 이벤트 부착. (= load메서드 = 로드 메서드)

목차
  1. load() 예제 - 이미지 로드 완료 후 경고창 띄우기.
  2. load() 정의
  3. load() 구문
  4. load() 예제 - 이미지 로드 완료 후 텍스트 변경.
  5. load() 예제 - 페이지 로드 완료 후 경고창 띄우기

 

 

load() 예제 - 이미지 로드 완료 후 경고창 띄우기

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

<script>

$(document).ready(function(){

  $("img").load(function(){

    alert("이미지 로드 완료.");

  });

});

</script>


<img src="https://source.unsplash.com/random" alt="Cinqueterra" width="304" height="236">

 

결과보기

 

load() 정의

 

이벤트 핸들러를 load 이벤트에 연결.

 


 

1.

jQuery 1.8 폐기예고. / jQuery 3.0 폐기완료.


2.

load 이벤트는 지정 요소 로드 완료 후 발생하며, URL (image, script, frame, iframe) 및 window 객체와 연결된 요소와 함께 작동.


3.

브라우저에 따라 이미지 캐시된 경우 (Firefox 및 IE), 로드 이벤트 발생 안 할 수도 있음.


참고 :

load()라는 jQuery AJAX 메서드도 있음. 

어느 것이 호출되는지는 매개변수에 따라 다름.

 

 

load() 구문

 

$(selector).load(function)

 


[매개변수]

 

function

필수. 지정 요소 로드 완료 후 실행할 내용.

 

 

load() 예제 - 이미지 로드 완료 후, 텍스트 변경.

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

<script>

$(document).ready(function(){

  $("img").load(function(){

    $("div").text("이미지 로드 완료");

  });

});

</script>


<img src="https://source.unsplash.com/random" alt="unsplash" width="304" height="236">


<div>이미지 로딩 중.</div>

 

결과보기

 

load() 예제 - 페이지 로드 완료 후 경고창 띄우기

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

<script>

$(document).ready(function(){

  $(window).load(function(){

    alert("페이지 로드 완료.");

  });

});

</script>


<img src="https://source.unsplash.com/random" alt="unsplash" width="304" height="236">

 

결과보기


 

방문 감사합니다. (즐겨찾기 등록: Ctrl + D)

분류 제목
basic JQ - 제이쿼리 입문
basic JQ - 선행지식 / 포함요소
basic JQ - 시작 (= 버전 + 다운 + 설치 + 외부링크) (jQuery, down, CDN)
basic JQ - syntax ★ - 기본구문 (= 최적작동시점) + (즉시호출/즉시작동/즉시실행) 구문 (= IIF… 2
Selector JQ - selector ★★★★★ - 선택자 (= 제어할 요소선택) ※ this선택자 (=디스선택자)
Event JQ - event ★ - 이벤트 (= 메서드실행 촉발사건) ※ e 매개변수를 명시적으로 전달해야 하는 이유
Event JQ - $(document).ready() 메서드 ★ - 문서로드완료후 실행 (= ready메서드 = 다…
Event JQ - click() 메서드 ★ - click 이벤트발생/함수실행. (= click메서드 = 클릭 메서드…
Event JQ - dblclick() 메서드 ★ - dblclick 이벤트발생/함수실행. (= dblclick메서드 …
Event JQ - mouseenter() 메서드 ★★★ - mouseenter 이벤트발생/함수실행. (= mousee…
Event JQ - mouseleave() 메서드 ★ - mouseleave 이벤트발생/함수실행 (= mouseleav…
Event JQ - mousedown() 메서드 - mousedown 이벤트발생/함수실행. (= mousedown메서…
Event JQ - mouseup() 메서드 - mouseup 이벤트발생/함수실행. (= mouseup메서드 = 마우스…
Event JQ - hover() 메서드 ★ - hover 이벤트발생/함수실행. (= hover메서드 = 허버 메서드)
1/20
목록
 홈  PC버전 로그인 일본어
웹디자인언어
서버관리언어
고급코딩언어
그누보드
제작의뢰
Q&A 1
커뮤니티 2
웹유틸
회원센터
홈짱 PC버전 로그인