本文實例講述了jQuery查看選中對象HTML代碼的方法。分享給大家供大家參考,具體如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src='jquery-1.6.2.min.js'></script>
<title>jQuery查看選中對象HTML代碼</title>
</head>
<body>
<div>
<div id="hb">dsaf</div>
</div>
<script>
$(function(){
alert($("#hb").get(0).outerHTML);
});
</script>
</body>
</html>
運行結果為:
<div id="hb">dsaf</div>
(此處注意與innerHTML的區別!)