jQuery의 간단한 사용

웹페이지에 jQuery 추가

웹페이지에 jQuery를 추가하는 방법에는 여러 가지가 있습니다. 다음 방법을 사용할 수 있습니다.

  • jquery.com에서 jQuery 라이브러리 다운로드

  • Google에서 jQuery 로드와 같은 CDN에서 jQuery 로드

jQuery 다운로드

다운로드할 수 있는 jQuery 버전은 두 가지가 있습니다.

프로덕션 버전 - 실제 웹사이트에서 사용되며 간소화되고 압축되었습니다.

  • 개발 버전 - 테스트 및 개발용(압축되지 않은 읽기 가능한 코드)

  • 위의 두 버전 모두 jquery.com에서 다운로드할 수 있습니다.

  • jQuery 라이브러리는 HTML <script> 태그를 사용하여 참조할 수 있는 JavaScript 파일입니다:

<head>

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

</head>

참고: jQuery를 사용하려면 다운로드한 파일을 웹페이지와 동일한 디렉터리에 배치하세요.

대안

jQuery를 다운로드하고 호스팅하고 싶지 않다면 CDN(Content Delivery Network)을 통해 참조할 수도 있습니다.
Baidu, Youpaiyun, Sina, Google 및 Microsoft 모두 서버에 jQuery를 보유하고 있습니다.

사이트 사용자가 국내인 경우 바이두, 유파이윤, 시나 등 국내 CDN 주소를 사용하는 것이 좋습니다. 해외인 경우 구글, 마이크로소프트를 이용하시면 됩니다.

참고: 이 사이트의 모든 예제는 Baidu jQuery CDN 라이브러리를 사용합니다.

<head>

<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">

</script>

</head>


예:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>php.cn</title>
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
 <script>
 $(document).ready(function(){
 $("#hide").click(function(){
 $("p").hide();
 });
 $("#show").click(function(){
 $("p").show();
 });
 });
 </script>
</head>
<body>
 <p>欢迎大家来到php.cn</p>
 <button id="hide">隐藏</button>
 <button id="show">显示</button>
</body>
</html>
지속적인 학습
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php.cn</title> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("#hide").click(function(){ $("p").hide(); }); $("#show").click(function(){ $("p").show(); }); }); </script> </head> <body> <p>欢迎大家来到php.cn</p> <button id="hide">隐藏</button> <button id="show">显示</button> </body> </html>
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!