Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 引导转盘,缩略图超过9项_Jquery_Twitter Bootstrap - Fatal编程技术网

Jquery 引导转盘,缩略图超过9项

Jquery 引导转盘,缩略图超过9项,jquery,twitter-bootstrap,Jquery,Twitter Bootstrap,我使用此脚本创建滑块: 当图像数超过9时出现问题 缩略图编号10重定向到幻灯片0 11号到幻灯片1 幻灯片2第12页 这个代码有什么问题 $('#myCarousel').carousel({ interval: 4000 }); // handles the carousel thumbnails $('[id^=carousel-selector-]').click( function(){ var id_selector = $(this).attr("id"); va

我使用此脚本创建滑块: 当图像数超过9时出现问题

缩略图编号10重定向到幻灯片0

11号到幻灯片1

幻灯片2第12页

这个代码有什么问题

$('#myCarousel').carousel({
    interval: 4000
});

// handles the carousel thumbnails
$('[id^=carousel-selector-]').click( function(){
  var id_selector = $(this).attr("id");
  var id = id_selector.substr(id_selector.length -1);
  id = parseInt(id);
  $('#myCarousel').carousel(id);
  $('[id^=carousel-selector-]').removeClass('selected');
  $(this).addClass('selected');
});

// when the carousel slides, auto update
$('#myCarousel').on('slid', function (e) {
  var id = $('.item.active').data('slide-number');
  id = parseInt(id);
  $('[id^=carousel-selector-]').removeClass('selected');
  $('[id=carousel-selector-'+id+']').addClass('selected');
});

问题在于这一行:

var id = id_selector.substr(id_selector.length -1);
假设数字的长度为1个字符。改成这个。此版本在最后一个
-
位置之后开始:

var id = id_selector.substr(id_selector.lastIndexOf("-")+1);

这可能不是错误的代码。给我们看看你的html怎么样?