<table width = "200" height = "200">
  <tr>
    <td style = "background:#CCCCCC" onClick = "alert(this.style.background);">
      aaaaa
    </td>
  </tr>
</tabel>

解决方案 »

  1.   

    谢谢bencalie(Bencalie),可我这个TD的背景色是用Javascript动态设置的,还是获取不了啊。代码如下:<html>
    <head>
    <style type="text/css">
    .tdMouseOver {
    background:#666666;
    }</style>
    </head>
    <body>
    <table width = "200" height = "200">
      <tr>
        <td onMouseover = "this.className = 'tdMouseOver';" onClick = "alert(this.style.background);">
          aaaaa
        </td>
      </tr>
    </tabel>
    </body>麻烦帮一下,好吗?
      

  2.   

    <html>
    <head>
    <style type="text/css">
    .tdMouseOver {
    background:#666666;
    }</style>
    </head>
    <body>
    <table width = "200" height = "200">
      <tr>
        <td onMouseover = "this.className = 'tdMouseOver';" onClick = "alert(this.currentStyle.backgroundColor);">
          aaaaa
        </td>
      </tr>
    </tabel>
    </body>