1

我正在尝试设置一个如下图所示的页面。

http://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>

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

关于如何使它工作的任何想法?

4

1 回答 1

1

一个非常简单的方法:

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

演示

于 2013-01-13T17:24:49.623 回答