개발자의 길/jQuery
jQuery 사용하기
모쿠
2017. 4. 10. 11:29
<jQuery 다운로드 및 설정>
* jQuery 라이브러리를 포함시키는 방법
1. http://jquery.com/download/ 페이지에서 jQuery 라이브러리를 다운로드
-> WebContent/js 폴더에 복사
-> <script> 태그를 사용해서 복사한 js 파일을 html 파일에 포함
2. CDN(Content Delivery Network)에서 제공하는 링크 주소로 포함
1. http://jquery.com/download/ 페이지에서 jQuery 라이브러리를 다운로드
-> WebContent/js 폴더에 복사
-> <script> 태그를 사용해서 복사한 js 파일을 html 파일에 포함
2. CDN(Content Delivery Network)에서 제공하는 링크 주소로 포함
-> 링크 주소를 넣는 <script>태그에서 js 코드를 작성하면 안됨!
<01_setup.html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>jQuery</title> <!-- 방법1 --> <!-- <script src="js/jquery-3.2.0.min.js"> </script>--> <!-- 방법2 --> <script src="https://code.jquery.com/jquery-3.2.1.min.js"> </script> <script> // document가 다 등록된 후에 실행이 되기 때문에 // 스크립트를 head에서 선언해도 상관없음 $(document).ready(function() { $('h2').click(function() { $(this).hide(); }); }); </script> </head> <body> <h1>jQuery 사용하기</h1> <h2>클릭하세요! 그럼 제가 사라집니다.</h2> <h2>Another h2 tag</h2> </body> </html> | cs |
<출력화면>