id用字母开头试试看
"<td id=\"t_" + xmlMain.item(i).getAttribute("id") + "\" onmouseover=\"mouseOverTheTd('t_" + xmlMain.item(i).getAttribute("id") + "')\"> content... </td>" 

解决方案 »

  1.   

    td的id值改为"Td" + xmlMain.item(i).getAttribute("id") + "\">" ,还是不行。
      

  2.   

    lz把td的html打印出来看看是什么样的,就只有这些吗<td id="1" onmouseover="mouseOverTheTd('1')"> </td> 
      

  3.   

    <td id="1" onmouseover="mouseOverTheTd(this)"> </td>
      

  4.   

    那你js就要改成
    function mouseOverTheTd(tdId) 

        tdId.style.backgroundColor = "#f0f8ff"; 
      

  5.   


    如果这样写的话,function mouseOverTheTd()方法的参数该怎么接收?
      

  6.   

    你確定已經引用了 mouseOverTheTd(tdId) 所在的 js 文件了嗎?
      

  7.   


    确定引用了,我曾经把 function mouseOverTheTd(tdId){}放到创建<table>的js文件里了,情况依旧。
      

  8.   

    <td id=\" + xmlMain.item(i).getAttribute("id") + "\" onmouseover=\"mouseOverTheTd(this)\" </td>" 
      

  9.   


    接收时只要function mouseOverTheTd(_this){_this.style.background="yellow"};
    你仔细分析一下,是找不到tdId这个对象,还是说你的其他地方有错!
      

  10.   

    用this吧function mouseOverTheTd(obj) 

        obj.style.backgroundColor = "#f0f8ff"; 
    } js 中 <td> 创建字符串如下: 
    <td id=\" + xmlMain.item(i).getAttribute("id") + "\" onmouseover=\"mouseOverTheTd(this)\"</td>" 
      

  11.   

    在 function mouseOverTheTd(tdId) 

        document.getElementById(tdId).style.backgroundColor = "#f0f8ff"; 
    } 内加一個 alert(tdId);看看是什麽結果
      

  12.   

    谢谢楼上各位的热心帮助,尝试过改用 "onmouseover=mouseOverTheTd(this)" 来传值,不过问题还没解决。
    经过调试,发现错误是发生在调用 mouseOverTheTd(obj) 的时候,js不会去执行 mouseOverTheTd(obj) 大括号下的任何语句。而在创建 table 的方法最后加上一个语句去获取其中一个<td id="_Td1">的属性: "alert(document.getElementById("Td1").onmouseover);" ,页面在创建 table 后,弹出提示如下:
    function anonymous()
    {
    mouseOverTheTd(this)
    }
    是能够找到这个<td>的 onmouseover方法的。郁闷……
      

  13.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <META NAME="Generator" CONTENT="EditPlus">
      <META NAME="Author" CONTENT="">
      <META NAME="Keywords" CONTENT="">
      <META NAME="Description" CONTENT="">
     </HEAD>
    <script type="text/javascript" >
        function alertThis(_this) {
            //alert(_this.outerHTML);
            _this.style.background = "yellow";
    _this.innerHTML +="鼠标放到我身上,我变黄色了";
        }
        function addTable() {
            var tempStr = "<table><tr><td style='width:50px;height:30px;' onmouseover='alertThis(this)' >123我是动态填出来的</td></tr></table>";
            document.getElementById("addTable").innerHTML += tempStr;
        }
    </script>
     <BODY>
        <input id="Button1" type="button" value="添加一个表格到页面上"  onclick="addTable()"/>
        <div id="addTable"></div>
     </BODY>
    </HTML>你的情况模拟了一下,是不是差不多就是这个样子,是可以的!
      

  14.   

    楼上的朋友,谢谢你的代码,我终于发现问题了。
    我的 js 里是用 doucment.write(tempStr) 这样的方式写入 html 流的。
    看了你的代码后,我在html页面里我加上了一个 <div id="addTable"> ,然后用 document.getElementById("addTable").innerHTML += tempStr; 的方法写入 html 流,onmouseover 事件就能够使用了。
    看样子,document.write(string)似乎不这么简单。谢谢上面的所有朋友。