为什么我不能在底部使用 SlideNumber...??
我试图将 var SlideNumber = 3;
更改为 SlideNumber = 3;
但老实说,我在黑暗中摸索。
if(window.location.hash != '') {
var SlideNumber = 3;
$('.slideshow').cycle({
fx: 'blindY', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
speed: 700,
cleartype: 1,
startingSlide: $(window.location.hash).index(),
timeout: 3000,
after: function(curr,next,opts) {
$("#menu ul li:nth-child(SlideNumber)").addClass("active");
ready = true;
}
});
提前谢谢你。
最佳答案
要补充一点,您可以通过使用 .eq
来避免串联并稍微提高性能。过滤方法(采用从零开始的索引):
$("#menu ul li").eq(slideNumber-1).addClass("active");
关于javascript - 在 :nth-child( X ) won't work 中插入 VAL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5262115/