解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript">
    var a=[];
    function change(x){
    document.getElementById('test').innerHTML+=x;
    a.push(x);
    }
    function change2(){
    var div=document.getElementById('test');
    var t=div.innerHTML;
    var p=a.pop();
    if(p){
    var end=t.lastIndexOf(p);
    t=t.substring(0,end);
    div.innerHTML=t;
    }
    }
    </script>
    </head><body>
    <div id="test"></div>
    <input type="button" value="我的" onclick="change('我的')">
    <input type="button" value="名字" onclick="change('名字')">
    <input type="button" value="是zyx" onclick="change('是zyx')">
    <input type="button" value="删除上一步" onclick="change2()">
    </body>
    </html>
    类似这样试试
      

  2.   

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    </head>
    <body><div id='show'></div><button id='b1'>my</button>
    <button id='b2'>name</button>
    <button id='b3'>is zjx</button>
    <button id='clear'>clear one</button>
    <script type="text/javascript">
    function $(id){
    return document.getElementById(id);
    }
    function init(){
    var sets=[];
    function b1fn(){
    if(!b1fn.clicked){
    sets.push('my');
    //b1fn.clicked=true;
    $('show').innerHTML=sets.join('');
    }
    }
    function b2fn(){
    if(!b2fn.clicked){
    sets.push(' name');
    //b2fn.clicked=true;
    $('show').innerHTML=sets.join('');
    }
    }
    function b3fn(){
    if(!b3fn.clicked){
    sets.push(' is zjx');
    //b3fn.clicked=true;
    $('show').innerHTML=sets.join('');
    }
    }
    function clear(){
    sets.pop();
    $('show').innerHTML=sets.join('');
    }


    $('b1').addEventListener('click',b1fn);
    $('b2').addEventListener('click',b2fn);
    $('b3').addEventListener('click',b3fn);
    $('clear').addEventListener('click',clear);
    }
    init();</script></body>
    </html>
      

  3.   

    按楼上朋友的思路可以解决你的问题.可以修改成这样:
    function change2(){
        a.pop();
        document.getElementById('test').innerHTML=a.join('');
    }