1

需要将图片id设为数字

var number = $(this).attr('rel');
    number = parseInt(number);
    $('#carousel .slides li:nth-child(' + (number + 1) + ')').click();
    $('#carousel').flexslider({

我的意思是替换 number = parseInt(number); 到图像的 id

文本

<article class="col img_prev2">
  <img src="img/slideshow/slideshow2.jpg" alt="#img2" rel="1" class="thumb_main_page">
   <h5>Text</h5>
</article>

在 rel 属性上方从 0 ( rel="0" )开始,所以我需要将其设置为例如 slideshow1.jpg instated "0" 。

4

1 回答 1

1

不知道要求什么,但这是?:

var count = 0;
$("img").each(function(){
   //start 0, then 1, then 2..
   $(this).attr("rel",count++); 
});

http://jsfiddle.net/jA8CW/

于 2013-04-06T08:50:15.033 回答