<SCRIPT LANGUAGE="JavaScript">
<!--
function changeSpan(o){
var n = o.childNodes[0];
if(n){
if(n.innerText=="30")
n.innerText = "20";
else
n.innerText = "30";
}
}
//-->
</SCRIPT>
<table>
<td id="intCell1" onclick="changeSpan(this);">
<span>30</span></td>
</table>

解决方案 »

  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=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript">
    function xlh(){
    var intCell = document.getElementById("intCell1");
    intCell.getElementsByTagName("span").item(0).firstChild.nodeValue = 40;
    }
    </script>
    </head><body>
    <table width="500" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td id="intCell1"><span>30</span></td>
      </tr>
      <tr>
        <td><input type="button" value="改变" onclick="xlh();" /></td>
      </tr>
    </table></body>
    </html>
      

  2.   

    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function changeSpan(){
    document.getElementById("sp").innerText="20";
    }
    //-->
    </SCRIPT>
    <table>
    <td id="intCell1" onclick="changeSpan()">
    <span id=sp>30</span></td>
    </table>
      

  3.   

    function changeSpan(obj)
    {
      obj.getElementsByTagName("span").item(0).firstChild.nodeValue = 20;
    }