<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<script type="text/javascript" src="../js/jquery-1.8.0.js"></script>
</head>
<body>
<h1>DOM 对象转成 jQuery 对象 示例</h1>
<script type="text/javascript">
$(document).ready(function() {
//1、jQuery 对象是一个数组对象, 可以通过 [index] 的方法得到对应的 DOM对象.
var $div2=$("#myid");
$div2.click(function(){
alert($div2);
var dom=$div2[0];
alert(dom.title);
});
//2、使用 jQuery 中的 get(index) 方法得到相应的 DOM 对象
var $div3=$(".myclass");
$div3.click(function(){
alert($div3);
var dom2=$div3.get(0);
alert(dom2.title);
});
});
</script>
<div id="myid" title="myid">
<p>hello jquery myid</p>
</div>
<div class="myclass" title="myclass">
<p>hello jquery myclass</p>
</div>
</body>
</html>