1.DOM对象:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="jQuery/jquery-1.10.2.js"></script>
<script type="text/javascript">
function test(){
var dom_obj=document.getElementById("p1");
alert(dom_obj.innerHTML);
}
</script>
<body>
<p id="p1">这是第一段文字</p>
<p id="p2">这是第二段文字</p>
<input type="button" value="dom对象" onclick="test()">
</body>
</html>
2.jQuery对象:
jQuery对象就是通过jQuery包装DOM对象后产生的对象。
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="jQuery/jquery-1.10.2.js"></script>
<script type="text/javascript">
function test(){
alert($("#p1").html());
}
</script>
<body>
<p id="p1">这是第一段文字</p>
<p id="p2">这是第二段文字</p>
<input type="button" value="jQuery对象" onclick="test()">
</body>
</html>