1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>无标题文档</title> 6 </head> 7 8 <body> 9 <input type="button" value='添加1' onclick='add()'/> 10 <input type='button' value='添加2'/> 11 <ul></ul> 12 13 </body> 14 <script> 15 function add(){ 16 var oUl=document.getElementsByName('ul')[0]; 17 oUl.innerHTML='<li>山有木兮木有枝,心悦君兮君不知</li><li>人生若只如初见,何事秋风悲画扇</li><li>去年今日此门中,人面桃花相映红。</li>'; 18 } 19 </script> 20 21 </html>
哪里出错了
var oUl=document.getElementsByTagName('ul')[0];