jQuery(제이쿼리)는
책처럼 필요한 것만 쏙쏙 골라 쓸 수 있는 라이브러리이다.
자세히는 자바스크립트 라이브러리.
< 파일 다운 받아 적용하기 >
파일 다운은
구글에 제이쿼리라고 검색하거나
Download jQuery | jQuery
link Downloading jQuery Compressed and uncompressed copies of jQuery files are available. The uncompressed file is best used during development or debugging; the compressed file saves bandwidth and improves performance in production. You can also download
jquery.com
여기서 들어가서 받고
다운 받으면 파일이 내 파일로 쏙 들어옴.
그럼 그 파일을 내가 작업하는 파일에
script 이용해서 연결해주기
<html>
<head>
</head>
<body>
<script src="제이쿼리파일임.js"></script>
<!-- jQuery라고 구글에 치면 나옴 다운 후 그 파일을 작업하는 파일에 넣고 연결해주기 -->
</body>
</html>
< 링크로 복붙해서 적용하기 >
다운 받기 귀찮으면
링크를 따올 수도 있음
jQuery cdn이라고 치거나
이 밑에 링크 들어가면됨.
jQuery CDN
The integrity and crossorigin attributes are used for Subresource Integrity (SRI) checking. This allows browsers to ensure that resources hosted on third-party servers have not been tampered with. Use of SRI is recommended as a best-practice, whenever libr
releases.jquery.com
그리고 그걸 똑같이 script 안에 넣어서 적용시켜주기
사실 저 링크 복사만 하면 script까지 타이핑 안쳐도 되게 친절하게 셋팅되있음.
<html>
<head>
</head>
<body>
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous">
</script> <!-- 다운 받기 귀찮으면 jQuery cdn이라고 치면 주소가 나옴 그걸 복붙 ㄱ -->
</body>
</html>
짜잔 이렇게 적용 끝!

< 사용법 >
사용할 때는 만들어주신 파일이나 링크 밑에서
제이쿼리 문법 적어서 사용하면 됨.
<html>
<head>
</head>
<body>
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous">
</script>
<script>
제이쿼리 문법 샬라샬라
</script>
</body>
</html>
<위치>
head 태그 안에 넣으면
HTML은 코드를 읽을때
책 읽듯이 위에서 아래로 읽어서
body 안에 넣은 코드 읽기 전에
잠깐 멈추고 외부 js 파일인 제이쿼리를 읽으러
휙 갔다가 다시 body 안에 넣은 코드 읽으러 옴.
그럼 사이트가 느려짐.
느린 사이트 만들고 싶으면 추천👍
<html>
<head>
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous">
</script>
</head>
<body>
<script>
제이쿼리 문법 샬라샬라
</script>
</body>
</html>
그래서 제일 최적의 제이쿼리 위치는
<html>
<head>
</head>
<body>
<div>
body
내용
샬라샬라
~~~~~
~~~~~
~~~~~
</div>
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous">
</script>
<script>
제이쿼리 문법 샬라샬라
자바스크립트 문법 샬라샬라
</script>
</body>
</html>
이렇게 body 태그 끝나기 전의 위치에 넣기!
그리고 요즘은 내가 만든 자바스크립트도 여기에 넣는게 제일 이상적임.
< jQuery cdn 버전 설명 >
uncompressed : 그냥 원본 파일
minified : 공백 다 제거해서 압축한 파일
slim : 기능이 많이 빠진 가벼운 파일
slim minified : 기능 빠지고 공백까지 제거된 이 중에서 제일 가벼운 파일

'끄적끄적' 카테고리의 다른 글
| JS) Class 문법 사용하기 (function 코드랑 비교) (0) | 2022.07.26 |
|---|---|
| HTML 내용 변경하기 : 자바스크립트랑 제이쿼리랑 비교 (0) | 2022.07.26 |
| [코드스니펫] - 한글 사용을 위한 세팅 (0) | 2022.07.24 |
| [드라마로 일본어] お言葉に甘えて (0) | 2022.07.23 |
| [드라마로 일본어 공부하기] 상담받다를 존댓말로? (0) | 2022.07.23 |
댓글