忘了说了,我把网页上传到我的测试网站上了。可以打开看效果,当然也可以复制代码保存看效果。
网址:jaon.free3v.net

解决方案 »

  1.   


    //获得文本框的父节点td
    //                        var tdp = inputs[i].parentNode;
                            //为text文本框的得到焦点事件绑定方法
                            inputs[i].onfocus = function (e) { setBgColor(e.target); };
                            //为text文本框的失去焦点事件绑定方法
                            inputs[i].onblur = function (e) { clearBgColor(e.target); };
      

  2.   

    我试下,晕,我不知怎么回复你,这样不知道你能不能看到。。
    //为text文本框的得到焦点事件绑定方法
                            inputs[i].onfocus = function () { setBgColor(this); };
                            //为text文本框的失去焦点事件绑定方法
                            inputs[i].onblur = function () { clearBgColor(this); };
    上面的在chrome下好的
      

  3.   

     function binding() {
                var inputs = document.getElementsByTagName("input");            for (var i = 0; i <inputs.length; i++) {                if (inputs[i].getAttribute("type") == "text") {
    //获得文本框的父节点td
                        //var tdp = inputs[i].parentNode;
    //为text文本框的得到焦点事件绑定方法
                        inputs[i].onfocus = function () { setBgColor(this.parentNode); };
    //为text文本框的失去焦点事件绑定方法
                        inputs[i].onblur = function () { clearBgColor(this.parentNode); };
                    }
                }
    你那样的话最后都是去获取最后的 tdp = inputs[i].parentNode;
      

  4.   

    我试下,晕,我不知怎么回复你,这样不知道你能不能看到。。
    //为text文本框的得到焦点事件绑定方法
                            inputs[i].onfocus = function () { setBgColor(this); };
                            //为text文本框的失去焦点事件绑定方法
                            inputs[i].onblur = function () { clearBgColor(this); };
    上面的在chrome下好的
    第一个我在360..上试的,好像不行。第二个可以,谢谢你啊,分给你了,我结贴了,非常感谢
      

  5.   

    闭包的问题。在你获得焦点的时候,i是遍历最后的结果,所以i=inputs.length-1;那么在你进行tdp = inputs[i].parentNode;取值的时候,就只能取到最后一个了。
      

  6.   

    咦,我不是结贴了吗?怎么还能回复。谢谢你们了 我知道了,,不用jquery是因为我想把js掌握好点再用jquery,它确实强大