1.上面的代码中 时间句柄写的不对
   <button onclick="_insertNOde()">插入 </botton>  调用是_insertNode()
2.liVal 这个对象 没有声明就使用了 if(liVal.value!=""){ 

解决方案 »

  1.   


    <html> 
      <head> 
        <title>test </title> 
      </head> 
      <script type="text/JavaScript"> 
    //      function _insertNode(){ //err:_insertN "o" de()--与onclick="_insertNOde()"不一致
          function _insertNOde(){ 
              if(liVal.value!=""){ 
    //            var newNode = document.createElement(li); //err:li--加引号
                var newNode = document.createElement("li"); 
                newNode.innerText=liVal.value; 
    //            list.appendChild(newNode); //err:l“i”st--拼写(id="last")
                last.appendChild(newNode); 
              } 
          }   </script> 
      <body> 
        <div id="last"> 
          <li> 
            a-1 
          </li> 
          <li> 
          b-1 
          </li> 
        </div> <br/> 
        <input type="text"id="liVal"/> 
        <button onclick="_insertNOde()">插入 </botton> 
        <button onclick="_removeNOde()">称除 </botton> 
        <button onclick="_replaceNOde()">代替 </botton> 
      </body> 
    </html> 
      

  2.   

    你的代码有几处书写格式的错误:
    1. <script> ... ... </script> 应该在<head></head>以内;
    2.</botton> 拼写错误;
    3._insertNOde 的O不应该大写;
    4.第一个和第二个<div>元素标签使用不规范;
    5.创建的新节点,并没有使用,append方法,添加到DOM模型中;
    6.本例中,在<body>体中,已经有了你的<div id="xxx"> 就不需要创建新的节点了.
    建议重新按照书上的例子,重新做一次.
      

  3.   

    回5楼,对于你说的第一点。<script></scriopt>应该放在<head></head>以内。不一定非要这样做有的时候如果功能不是非常复杂的话可以直接放在body里,只要保证dom可寻就行了。