<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
function getValue()
{
var x=document.getElementById("myHeader")
var y= $("#test #myHeader")[0];
alert(x.innerHTML);
alert(y.innerHTML);
}
</script>
</head>
<body>
<div id="test">
<h1 id="myHeader" onclick="getValue()">这是标题</h1>
</div>
<p>点击标题,会提示出它的值。</p>
</body>
</html>
网友评论