Library/JQuery

๐Ÿ“š jQuery ์„ค์น˜ & ์ ์šฉ ๋ฐฉ๋ฒ•

์ธํŒŒ_ 2021. 9. 27. 22:08

์ œ์ด์ฟผ๋ฆฌ

์ œ์ด์ฟผ๋ฆฌ ์„ค์น˜

ํ•œ๋•Œ ์ „์„ธ๊ณ„์—์„œ ๊ฐ€์žฅ ๋งŽ์ด ์“ฐ๋˜ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜ & ์ ์šฉ ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ํฌ์ŠคํŒ… ํ•ด๋ณธ๋‹ค.

 

1. ๋กœ์ปฌ ๋‹ค์šด๋กœ๋“œ ๋ฐฉ๋ฒ•

์•„๋ž˜ ๋งํฌ๋กœ ๋“ค์–ด๊ฐ€ jquery ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œ ํ•œ๋’ค, ์ž์‹ ์˜ ํ”„๋กœ์ ํŠธ์— ๋„ฃ์œผ๋ฉด ๋œ๋‹ค.

 

jQuery

What is jQuery? jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.

jquery.com

์ œ์ด์ฟผ๋ฆฌ
์ œ์ด์ฟผ๋ฆฌ
์ œ์ด์ฟผ๋ฆฌ

โ€‹

๊ทธ๋ฆฌ๊ณ  html์˜ headํƒœ๊ทธ์—์„œ src๋ฅผ ์ง€์ •ํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

<head>
   <script src="./jquery-3.4.1.min.js"></script>
</head>

2. CDN์œผ๋กœ ๋ถˆ๋Ÿฌ์˜ค๋Š” ๋ฐฉ๋ฒ•

โ€‹์•„๋ž˜ ๋งํฌ์—์„œ ์ฝ”๋“œ๋ฅผ ๋ณต์‚ฌํ•˜๊ณ  html์— ๋„ฃ์œผ๋ฉด ๋œ๋‹ค.

 

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

code.jquery.com

์ œ์ด์ฟผ๋ฆฌ
์ œ์ด์ฟผ๋ฆฌ

<script src="https://code.jquery.com/jquery-3.6.4.min.js" integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script>

์ œ์ด์ฟผ๋ฆฌ ์ ์šฉ ์˜ˆ์‹œ

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
    <div id="test"></div>
    <script>
        $('#test').html('์ œ์ด์ฟผ๋ฆฌ ํ…Œ์ŠคํŠธ').css('border','1px solid blue')
        // ์ œ์ด์ฟผ๋ฆฌ๋Š” ์ž๊ธฐ์ž์‹  ์—˜๋ฆฌ๋จผํŠธ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๊ธฐ ๋–„๋ฌธ์—, ์ฒด์ด๋‹ ๊ธฐ๋ฒ•์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
    </script>
</body>
</html>