on
1027_jQuery : jQuery, Core
1027_jQuery : jQuery, Core
<%@ page contentType="text/html; charset=UTF-8"%> <%@ page trimDirectiveWhitespaces="true"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> Insert title here // DOM이 로드 될 때 실행 /* // 이벤트 핸들러 프로퍼티 방식 // 테스트-2 만 실행 window.onload = function() { console.log("테스트-1"); }; window.onload = function() { console.log("테스트-2"); }; */ /* // addEventListener // 둘 다 실행 window.addEventListener("load", function() { console.log("테스트-1"); }); window.addEventListener("load", function() { console.log("테스트-2"); }); */ /* // jquery를 이용한 실행 // 둘 다 실행 jQuery(document).ready(function() { console.log("테스트-1") }); jQuery(document).ready(function() { console.log("테스트-2") }); */ /* // jQuery(document).ready(function(){}); 의 짧은 표현 jQuery(function(){ console.log("테스트-1"); }); jQuery(function(){ console.log("테스트-2"); }); */ /* // jQuery === $ $(function(){ console.log("테스트-1"); }); $(function(){ console.log("테스트-2"); }); */ /* $(document).ready(function() { // DOM 객체만 로드 되면 바로 실행 console.log("테스트-1"); }); $(window).on("load", function() { // 해당 페이지의 모든 외부 리소스(이미지, css 등)가 로드 된 후 실행 // $(function(){}); 보다 느림 console.log("테스트-2"); }) */ $(function() { $(document.body).css("background", "#eee"); }); jQuery Core 예제 jQuery( elements ), $( elements ) $() = $(document).ready() = jQuery() = jQuery(document).ready()
from http://development-writing.tistory.com/336 by ccl(S) rewrite - 2021-10-28 08:28:18