posted by 방랑군 2012. 1. 8. 20:49

1. test2.jsp

01 <%@ page contentType="text/html; charset=UTF-8"%>
02 <%
03 String cp = request.getContextPath();
04 %>
05 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
06 <html>
07 <head>
08 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
09 <title>Insert title here</title>
10
11 <!-- jQuery 사용시 jquery-1.X.X.min.js 파일 연결 필수 -->
12 <script type="text/javascript" src="<%=cp%>/js/jquery-1.6.1.min.js" ></script>
13
14 <script type="text/javascript">
15 //jQuery는 $(선택자) 또는 jQuery(선택자)로 시작한다.
16 //$() 또는 $(document).ready()는
17 //문서가 사용 가능한 시점에 자동으로 인식해서 실행됨.
18 //$(function() { })와
19 //$(document).ready(function() { })는 같은 표현
20 $(document).ready(function() {
21 alert("Hello, JavaScript");
22 });
23 $(document).ready(function() {
24 alert("Hello, jQuery");
25 });
26 </script>
27
28 </head>
29 <body>
30 <h1>jQuery 테스트</h1>
31 jQuery에서 동일한 이벤트 등록시 둘 다 실행됨.
32 </body>
33 </html>

실행 결과