如何在将鼠标悬停在另一个链接上时更改表格背景图像

How to change table background image upon mouseover of another link

本文关键字:背景 图像 表格 链接 鼠标 悬停 另一个      更新时间:2023-09-26

我有这个来更改div.fullscreen的背景图像:

<div id="swatches">
  <a href="http://www-03.ibm.com/ibm/history/exhibits/storage/images/PH3380A.jpg">
    <img src="http://www.wmagency.co.uk/wp-content/uploads/2011/04/test.jpg"
         onmouseover="document.images['bigPic'].src='http://josefsipek.net/docs/s390-    linux/hercules-s390/ssh-dasd1.png';"
         width="72" height="54" alt="Item ksc1" />
  </a>
</div>

但是,有没有办法在另一个图像链接hover更改表格的背景图像?

当然,看看这里的例子。

这是通过给img一个idtable一个id来完成的。然后我们监听鼠标何时在img上,当它这样做时, 更改table background-image .

只想使用内联 JavaScript?使用这个:

<div id="swatches">
  <a href="http://www-03.ibm.com/ibm/history/exhibits/storage/images/PH3380A.jpg">
    <img src="http://www.wmagency.co.uk/wp-content/uploads/2011/04/test.jpg"
         onmouseover='document.getElementById("table_id_here").style["background-image"]="url(''http://www.gravatar.com/avatar/'');'
         width="72" height="54" alt="Item ksc1" />
  </a>
</div>