更改图像链接悬停在文本列表

Change Image with link hover a text list

本文关键字:文本 列表 悬停 链接 图像      更新时间:2023-09-26

我正在尝试建立一个看起来像下图的页面。

https://i.stack.imgur.com/GwRXf.png

我想有主图像替换当我"悬停"在附近列出的链接之一(表或列表)禁用"点击"行为。

我已经尝试这样做与css下面的代码:http://jsfiddle.net/Kne3d/5/

我试着这样改变它:

#gallery {
    oveflow: auto;
    text-align: center;
    padding: 1em;
    padding-top: 120px;
    position: relative;
}
#gallery td {
    display: inline;
    padding: 0 1em;
}
#gallery img {
    display: none;
    position: absolute;
    top: 10px;
    left: 35%;
}
#gallery td:hover {
    background: yellow;
}
#gallery td:hover ~ img {
    display: block;
}

:

<table width="100%" border="0" cellspacing="0" cellpadding="0" id="gallery">
  <tr>
    <td width="100%">Cat 1<img src="/images/01.png"></td>
    <td width="150" rowspan="6">I WANT MY IMAGES HERE</td>
  </tr>
  <tr>
    <td>Cat 2 <img src="/images/02.png"></td>
  </tr>
  <tr>
    <td>Cat 3 <img src="/images/03.png"></td>
  </tr>
  <tr>
    <td>Cat 4<img src="/images/04.png">
</td>
  </tr>
</table>

我想让我的图像显示在右列…

我也尝试过Javascript:

<head>
    <script language="JavaScript" type="text/JavaScript"> 
    function showT(q){ 
    document.getElementById('ima').setAttribute('src','0'+q+'.png') 
    } 
    </script>
</head>
<body>
    <table width="100%" border="0">
      <tr>
        <td width="80%"><p><a href="#" onmouseover="showT(0)">• Image 1</a></p>
          <p><a href="#" onmouseover="showT(1)">Image 2</a></p>
          <p><a href="#" onmouseover="showT(2)">Image 3</a></p>
          <p><a href="#" onmouseover="showT(3)">Image 4</a></p>
    <td width="20%"><img id="ima" src="images/00.png" width="150" height="150">
      </td>
      </tr>
    </table>
</body>

但是…没有成功:图像不显示:(

你知道它是如何工作的吗?

一个非常简单的方法:

$('#nav').find('li').hover(function(){
  $('#gallery').find('li').eq($(this).index()).toggle();
});