我开始在我的网站上应用引导程序。我需要更改以下脚本以在引导轮播上工作
$(function(){
// Set starting slide to 1
var startSlide = 1;
// Get slide number if it exists
if (window.location.hash) {
alert('hash'+window.location.hash);
startSlide = window.location.hash.replace('#','');
alert('startslide'+startSlide);
}
// Initialize Slides
$('#slides2').slides({
preload: true,
preloadImage: 'img/loading.gif',
generatePagination: true,
play: 0,
pause: 2500,
hoverPause: true,
currentClass: 'current',
// Get the starting slide
start: {$startNumb},
animationComplete: function(current){
// Set the slide number as a hash
window.location.hash = '#' + current;
alert('windows hash'+window.location.hash);
alert('current'+current);
$('#activeSlideIndex').val(current);
$('#popLightbox div.rating a').attr('rel', imageIdArray[current-1] +';media');
$('#popLightbox a.voteNegative').html('<img src="{$liveSite}/templates/{$theme}/desktop_images/images/unlike.png" align="absmiddle"><b class="sprite"> </b> ' + voteCountArray[current-1][0]);
$('#popLightbox a.votePlus').html('<img src="{$liveSite}/templates/{$theme}/desktop_images/images/approve.png" align="absmiddle"><b class="sprite"> </b> ' + voteCountArray[current-1][1]);
}
});
我已经尝试过这样的事情,但它不起作用。我不知道该current
变量在哪里获得它的值以及如何window.location.hash
工作
$(function(){
// Set starting slide to 1
var startSlide = 1;
// Get slide number if it exists
if (window.location.hash) {
startSlide = window.location.hash.replace('#','');
}
$('#myCarousel').bind('slide',function(current){
window.location.hash = '#' + current;
$('#activeSlideIndex').val(current);
$('#popLightbox div.rating a').attr('rel', imageIdArray[current-1] +';media');
$('#popLightbox a.voteNegative').html('<img src="{$liveSite}/templates/{$theme}/desktop_images/images/unlike.png" align="absmiddle"><b class="sprite"> </b> ' + voteCountArray[current-1][0]);
$('#popLightbox a.votePlus').html('<img src="{$liveSite}/templates/{$theme}/desktop_images/images/approve.png" align="absmiddle"><b class="sprite"> </b> ' + voteCountArray[current-1][1]);
});
});