본문 바로가기

웹 프로그래밍/jQuery

[jQuery] $(window).load() .resize() .scroll() .ready()

$(window) : jQuery window 객체

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<!-- <script src="/Lecture-WEB/jquery/js/jquery-3.5.1.min.js"></script> -->
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
	$(window).load(function() { //1점대의 jQuery에서만 먹힘
		console.log('load...')
	})
	
	$(window).resize(function() {
		console.log('resize...')
	})
	
	$(window).scroll(function() {
		console.log('scroll...')
	})
	
	$(document).ready(function() { // ready - load 순으로 실행된다
		console.log('ready...')
	})
</script>
</head>
<body>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
	<h1>Hello</h1>
</body>
</html>