繁体   English   中英

数字= parseInt(数字); 需要不使用rel属性进行编号

[英]number = parseInt(number); need to make not number from rel attribute

需要设置编号的图片ID

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

我的意思是替换数字= parseInt(数字); 到图片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”),所以我需要使其例如为showshow1.jpg设置为“ 0”。

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

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

http://jsfiddle.net/jA8CW/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM