document.getElementById("aa"); 获取id=aa的元素

node2:/var/www/html/jquery#cat t3.html 
<htmL>
  <head>
   <title>aaa</title>
   </head>
   <body>
     <h3>例子</h3>
	 <p title="选择你喜欢的水果.">你最喜欢的水果是?</p>
	 <ul>
	   <li id='aa'>苹果</li>
	   <li id='bb'>橘子</li>
	   <li id='cc'>菠萝</li>
	   <li id='dd'>雪梨</li>
	 </ul>
<script type="text/javascript" src="jquery-2.2.2.min.js"></script>
<script type="text/javascript" src="t3.js"></script>
node2:/var/www/html/jquery#


node2:/var/www/html/jquery#cat t3.js
var domObj = document.getElementById("aa"); //获得DOM对象   获取id=aa的元素
console.log(domObj.innerHTML);

猜你喜欢

转载自blog.csdn.net/zhaoyangjian724/article/details/88397441
AA