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)

분류 제목
Selector JQ - :checkbox 선택자 - type="checkbox"인 input 요소 선택 (= 체크박스선택자…
Selector JQ - :submit 선택자 - type="submit"인 input, button 요소 선택. (= 서브…
Selector JQ - :reset 선택자 - type="reset"인 input, button 요소 선택. (= 리셋 선…
Selector JQ - :button 선택자 - type="button"인 input, button 요소 선택. (= 버튼…
Selector JQ - :image 선택자 - type="image"인 input 요소 선택. (= 이미지 선택자)
Selector JQ - :file 선택자 - type="file"인 input 요소 선택. (= 파일 선택자)
Selector JQ - :enabled 선택자 - 활성화 된 요소 선택. (= 인에이블드 선택자)
Selector JQ - :disabled 선택자 - 비활성화 된 요소 선택. (= 디서에이블드 선택자)
Selector JQ - :selected 선택자 - selected="selected"인 요소 선택. (= 실렉티드 선택자…
Selector JQ - :checked 선택자 - $(":checked") - checked="checked"인 모든 체크…
Event JQ - bind() 메서드 - JQ 3.0 폐기예고. / 요소에 이벤트 부착. (= bind메서드 = 바인…
Event JQ - change() 메서드 ★★★ - 입력값 변동/변화 시 이벤트 발생. (= change메서드 = …
Event JQ - delegate() 메서드 - JQ 3.0 폐기예고. / 하위요소(자식요소)에 이벤트핸들러 부착. …
Event JQ - die() 메서드 - JQ 1.7 폐기예고, JQ 1.9 폐기완료. / 이벤트 제거. (= die메…
Event JQ - error() 메서드 - JQ 1.8 폐기예고. JQ 3.0 폐기완료. / 에러 이벤트 촉발 + 에…
7/20
목록
 홈  PC버전 로그인 일본어
웹디자인언어
서버관리언어
고급코딩언어
그누보드
제작의뢰
Q&A
커뮤니티
웹유틸
회원센터
홈짱닷컴 PC버전 로그인