0

我希望能够单击拇指并在图库中显示更大的图片。这是我的看法。

看法

<div class="gallery">

 <ul class="slideshow">
  <% @images.each do |img|%>
   <li>
      <%= link_to image_tag(...), :alt => img.name ), img %>
   </li>
  <% end %>
</ul>

<div class="thumbs">
 <% @images.each do |img|%>
 <a href="javascript:void(0)" rel="<%= img.images... %>" class="slideshow">
   <%= image_tag(...)%>
 </a>
<% end %>
</div>

</div>

这是我的js代码

js

function click() {

$('.thumbs').click(
function() {
var gallery = $(this).attr("rel");
$('ul.slideshow').removeClass('show');
$(this).addClass('show');
$('slideshow').html('<img src="' + gallery + '" />');
return false;
})
}

但它似乎不起作用。现在,较大的幻灯片也有一个 setInterval,因此所有不同的较大图像都会旋转。

4

1 回答 1

0

为什么在 click() 函数中使用 this.. 你可以直接这样使用..

$('.thumbs').click(function() {
var gallery = $(this).attr("rel");
$('ul.slideshow').removeClass('show');
$(this).addClass('show');
$('slideshow').html('<img src="' + gallery + '" />');
return false;
});
于 2012-04-26T04:58:43.047 回答