node2:/var/www/html/jquery/aa#cat a7.html
<html>
<body>
<div id='ID'>测试页面</div>
<script type="text/javascript" src="jquery-2.2.2.min.js"></script>
<script type="text/javascript" src="a7.js"></script>
</body>
</html>
node2:/var/www/html/jquery/aa#cat a7.js
var name=document.getElementById('ID').innerHTML;
console.log(name);
使用jQuery 语法:
.html()用为读取和修改元素的HTML标签 对应js中的innerHTML
node2:/var/www/html/jquery/aa#cat a7.js
var name=$("#ID").html();
console.log(name);