1 document.getElementById();根据id找 2 document.getElementsByclassName();根据类名class找 3 document.getElementsByName();根据名称找 4 document.getElementsByTagName();根据标签p,h1的名字找
可以把bbc显示在h1标签里面
1 <h1 id="aa"></h1> 2 <script> 3 var hh = document.getElementById('aa'); 4 hh.innerHTML = 'bbc'; 5 </script>
1 var hh = document.getElementsByTagName('h1')[0]; 2 hh.innerHTML = 'ok';