โญ๏ธ jQuery โญ๏ธ
01. jQuery๋?
์ ์ด์ฟผ๋ฆฌ(jQuery)๋ ์น์ฌ์ดํธ์ ์๋ฐ์คํฌ๋ฆฝํธ๋ฅผ ์ฝ๊ฒ ํ์ฉํ ์ ์๋๋ก ๋์์ฃผ๋, ์คํ์์ค ๊ธฐ๋ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์
๋๋ค.
์ ์ด์ฟผ๋ฆฌ๋ ๋ง์ดํฌ๋ก์ํํธ์ ASP.NET ํ๋ ์์ํฌ, ์๋ํ๋ ์ค ๋ฑ ๋ค์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ํ๋ ์์ํฌ์ ํฌํจ๋๋ฉด์ ์น ํ๋ก ํธ์๋ ๋ถ์ผ์์ ์ ์ ์จ์ด ์ง์์ ์ผ๋ก ์์นํ์์ผ๋, ํ์ฌ ๋์ ๊ธฐ๋ฅ์ฑ์ ๊ฐ์ถ ์น ํ์ค API๊ฐ ๋์ด๋๋ฉด์ ์ ์ด์ฟผ๋ฆฌ์ ์ธ๊ธฐ๋ ๋ฎ์์ง๊ณ ์์ต๋๋ค.
02. jQuery ์ฌ์ฉ ๋ฐฉ๋ฒ
jQuery ๋ผ์ด๋ธ๋ฌ๋ผ ํ์ผ ํ์์๋ ์ค๋ช
์ ๋ํ ์ฃผ์ ์ฐจ์ด์ ๋ฐ๋ผ ์์ถ ํ์ผ๊ณผ ๋น์์ถ ํ์ผ ํ์์ด ์์ต๋๋ค.
์ผ๋ฐ์ ์ผ๋ก ์ค๋ช
์ด ํฌ๊ฒ ํ์์น ์์ผ๋ฏ๋ก, ์์ถ ํ์ผ์ ์ฌ์ฉํฉ๋๋ค.
[1] Download ๋ฐฉ์
ํ์ผ์ ์ง์ ๋ค์ด๋ฐ์ ์ฐ๊ฒฐํ๋ ๋ฐฉ์ ์ ๋๋ค.
1) jQuery ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ค์ด๋ก๋
http://jquery.com/download ์ ์ ์ํ์ฌ 'Download the compressed, production jQuery 3.3.1' ์ ๋ค์ด๋ก๋ ํฉ๋๋ค.
ํฌ๋กฌ ๋ธ๋ผ์ฐ์ ์์ ๋ค์ด ๋ฐ์ ๊ฒฝ์ฐ, ์นํ์ด์ง์ ์๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฝ๋ ์ ์ฒด๋ฅผ ๋ณต์ฌํ์ฌ ์น ์๋ํฐ์ ๋ถ์ฌ๋ฃ๊ณ jquery-3.3.1.min.js ๋ก ์ ์ฅํด์ค๋๋ค.
2) HTML ์์ jQuery ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฐ๊ฒฐ
html ๋ฌธ์๋ฅผ jQuery ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๊ฐ์ ๊ฒฝ๋ก์ ์ ์ฅํฉ๋๋ค.
์ ์ฐ๊ฒฐ๋์๋์ง ํ์ธํ ๋์๋ $(document).ready() ๋ฅผ ์ฌ์ฉํด๋ด
๋๋ค.
[2] CDN ๋ฐฉ์
๋ฐ์ดํฐ๋ฅผ ๋ฐ์์ค๋ ์๋ฒ์ ์ฃผ์๋ฅผ ์ฐ๊ฒฐํ๋ ๋ฐฉ์ ์
๋๋ค.
์ฐธ๊ณ : jQuery Quick API Reference ์์ ๋ฐ์ดํฐ๋ฅผ ๋ฐ์์ค๋ ์๋ฒ์ ์ฃผ์๋ฅผ ๋ฐ์ ์ ์์ผ๋ฉฐ, ํ์ฉ๋ฒ์ ์ฐพ์๋ณด๊ณ ์ ์ฉ์ํฌ ์ ์์ต๋๋ค.
1) CDN ์ฃผ์ ๋ณต์ฌ
http://code.jquery.com ์ ์ ์ํ์ฌ jQuery 3.3.1 - minified ๋ฒ์ ์ ์ ํํ๊ณ CDN ์ ๋ณต์ฌ ํฉ๋๋ค.
2) HTML ์์ jQuery ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฐ๊ฒฐ
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> // ๋ฐ์ดํฐ ์๋ฒ ์ฃผ์ ์
๋ ฅ
>
<script> // ์ธ๋ถ ์ค์ ๋ฐ ํ์ฉํ๊ธฐ
let currentIndex = 0;
setInterval(() => {
currentIndex = (currentIndex + 1) % $(".slider").length;
// $() = document.querySelector ์ ์ค์ฌ์ ์ด ๊ฒ
// $(".slider__inner").css(
// "transform", "translateX("+ -800 * currentIndex +"px)"
// );
$(".slider__inner").css("position", "relative");
$(".slider__inner").animate({
left : -800 * currentIndex
}, 600)
}, 2000);
</script>
03. jQuery ๊ธฐ๋ณธ ํ์
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>jQuery ๊ธฐ๋ณธ ํ์</title>
<script scr="jquery-3.3.1.min.js"></script>
<script>
$(document).ready(function() { // $(function() {์คํ๋ฌธ;}); ์ ์ฝ์์ผ๋ก ํํ ๊ฐ๋ฅ
์คํ๋ฌธ;
});
</script>
</head>
<body>
</body>
</html>
'Javascript > jQuery' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
jQuery ํด๋์ค ๊ด๋ จ ๋ฉ์๋ (3) | 2022.09.05 |
---|---|
jQuery ํ์ ์ ํ์ (3) | 2022.09.01 |
jQuery ํํฐ ์ ํ์ (3) | 2022.09.01 |
jQuery ์์ฑ ์ ํ์ (3) | 2022.09.01 |
jQuery ๊ธฐ๋ณธ ์ ํ์ (3) | 2022.09.01 |
๋๊ธ