定义和用法
getElementById() 方法可返回对拥有指定 ID 的第一个对象的引用。
语法
document.getElementById(id)
js 获取ID document.getElementById('elem').innerHTML = this.responseText;
虽然这里没有太难的代码,只有几行代码(17行),等价的jQuery代码如下:
<div id='aa'>divaa</div>
<li id='bb'>libb</li>
<li id='aa'>liaa</li>
<a id='cc'>acc</a>
<p id='aa'>paa</a>
<script>
console.log(document.getElementById('id').innerHTML);
</script>