"JQuery 시작하기"의 두 판 사이의 차이

6번째 줄: 6번째 줄:
*버전별 js파일은 http://code.jquery.com 에 있다.
*버전별 js파일은 http://code.jquery.com 에 있다.
*거기에는 또 같은 버전이라도 비압축 버전(uncompressed)과 압축버전(compressed)이 있다.
*거기에는 또 같은 버전이라도 비압축 버전(uncompressed)과 압축버전(compressed)이 있다.
*안정화 최신 버전은 http://code.jquery.com/jquery.js (일반버전)과 http://code.jquery.com/jquery.min.js (압축버전)이다. 이것으로 연결하면 jquery 측에서 안정화 버전을 올릴 때, 자동으로 업데이트가 되는 효과가 있다. 물론 이로 인해서 예전에 되던 기능이 되지 않을 수도 있을 것이다.
*안정화 최신 버전은 http://code.jquery.com/jquery.js (일반버전)과 http://code.jquery.com/jquery.min.js (압축버전)이다. 이것으로 연결하면 jquery 측에서 안정화 버전을 올릴 때, 자동으로 업데이트가 되는 효과가 있다.<ref>흔한 경우는 아니겠으나, 이로 인해서 예전에 되던 기능이 되지 않을 수도 있다.</ref>


==example01.php==
==example01.php==

2013년 9월 5일 (목) 22:40 판

jQuery 시작하기
jQuery 튜토리얼

1 어떤 js를 연결하는 것이 좋을까?

2 example01.php

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
</head>
<body>
<div>원래 내용 1</div>
<div>원래 내용 2</div>
<script type="text/javascript">
jQuery('div').text('새 내용');
</script>
</body>
</html>

2.1 실행결과

새 내용
새 내용

3 example01B.php

여기서는 div 부분과 script 부분의 순서를 바꿔보자. 그러면 실행결과는 어떻게 될까?

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
jQuery('div').text('새 내용');
</script>
</head>
<body>
<div>원래 내용 1</div>
<div>원래 내용 2</div>
</body>
</html>

3.1 실행결과

원래 내용 1
원래 내용 2
  • 새 내용으로 바뀌지 않고 원래 내용이 그대로 나온다.
  • 새 내용을 적용하라는 명령 이후에 "원래 내용"이 나오기 때문에, 나중에 나온 "원래 내용"이 적용된 것이다.
  • 예시: http://jmnote.com/jq/example01B.php

4 참고자료

5 같이 보기

  1. 흔한 경우는 아니겠으나, 이로 인해서 예전에 되던 기능이 되지 않을 수도 있다.
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}