2010-12-06 49 views
1

我在div上有5个图像(如产品的拇指图像)。而且我还有另外一个div,并附有简短的标签部分。通过点击另一个div中的图像显示div(具有样式“display:none”)

我的编码(如下面):

  1. 分度,5个图像。
  2. 另一个分部有5个选项卡部分及其产品详细信息。
  3. 另外,第二个div有财产style"display:none"。我想让它看到它的详细的div部分点击拇指。

在此先感谢。

+2

一些HTML会很好。 – 2010-12-06 17:59:09

回答

2

您可以使用.show().hide()来切换'display:none'来显示/隐藏div。

+1

更好,您可以使用.toggle()切换显示。 :) – bozdoz 2010-12-06 18:06:03

0

我的回答只能和你的描述一样。

$("#theDivToBeClickedOn").click(function(){ 
     $("#theDivWhereImageIs").show(); 
}); 
0

我假设你有一个有具体形象的描述,所以你必须显示/隐藏他们太多其他一些标签。

$('#div1 img').click(function(){ //when you click on the thumb in the first div 
     var i = $('#div1 img').index(this); //get index of thumb to correspond to image 
     $('#div3').toggle(); //show third div 
     $('#div3 div').eq(i).toggle(); //show the particular thumb's description 
}); 
相关问题