jQuery 학습 노트 2 -javascript와 jQuery 획득 대상의 차이

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
<script type="text/javascript" src="JS/jquery-1.6.2.js"></script>
<script type="text/javascript">
	//      
	$(document).ready(
		function (){
			var myLink = document.getElementsByTagName("a");
			for(var i=0;i<myLink.length;i++){
				myLink[i].onclick = function(){alert("      ");};
			}
		}
	);
	
	//  jQuery  
	$(document).ready(		
		function (){
			$("input").click(function(){
				alert("jQuery    !");
			});
		}
	);
</script>
<title>jQuery    1</title>
</head>
<body>
<p>
<a href="#">  1</a>
<a href="#">  2</a>
<a href="#">  3</a>
<a href="#">  4</a>
</p>

<p>
<input type="button" value="  1"/>
<input type="button" value="  2"/>
<input type="button" value="  3"/>
<input type="button" value="  4"/>
</p>
</body>
</html>

좋은 웹페이지 즐겨찾기