Javascript 转盘下一个/上一个按钮不工作
我正在尝试从中实现以下lightbox转盘 在我尝试旋转木马上的“上一步”和“下一步”按钮不起作用之前,一切都很顺利(尽管键盘上的左键和右键都起作用) 在查看我的js文件的其余部分后,我发现主题附带的以下代码影响了按钮,因为在我注释掉这段代码后,旋转木马按钮工作正常Javascript 转盘下一个/上一个按钮不工作,javascript,jquery,html,twitter-bootstrap,Javascript,Jquery,Html,Twitter Bootstrap,我正在尝试从中实现以下lightbox转盘 在我尝试旋转木马上的“上一步”和“下一步”按钮不起作用之前,一切都很顺利(尽管键盘上的左键和右键都起作用) 在查看我的js文件的其余部分后,我发现主题附带的以下代码影响了按钮,因为在我注释掉这段代码后,旋转木马按钮工作正常 // Smooth scroll on page hash links $('a[href*="#"]:not([href="#"])').on('click', function() { if (location.
// Smooth scroll on page hash links
$('a[href*="#"]:not([href="#"])').on('click', function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
if (target.length) {
var top_space = 0;
if( $('#header').length ) {
top_space = $('#header').outerHeight();
}
$('html, body').animate({
scrollTop: target.offset().top - top_space
}, 1500, 'easeInOutExpo');
if ( $(this).parents('.nav-menu').length ) {
$('.nav-menu .menu-active').removeClass('menu-active');
$(this).closest('li').addClass('menu-active');
}
if ( $('body').hasClass('mobile-nav-active') ) {
$('body').removeClass('mobile-nav-active');
$('#mobile-nav-toggle i').toggleClass('fa-times fa-bars');
$('#mobile-body-overly').fadeOut();
}
return false;
}
}
});
下面是我的转盘按钮的html。我猜平滑滚动代码在href=“#modal carousel”上拾取,导致它无法工作
<a class="carousel-control left" href="#modal-carousel" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i></a>
<a class="carousel-control right" href="#modal-carousel" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a>
有什么解决方法可以让这两个功能一起工作吗?通过添加
:not([href="#modal-carousel"])
到
为了让它忽略模式旋转木马,我在笔中粘贴了平滑滚动代码,但左右按钮仍在工作。我甚至通过放置调试器语句来确保平滑滚动代码的执行。你能像第一个注释一样一个接一个地注释掉特定的部分吗:if($('#header').length){//code}部分,然后是其他部分,并得出导致问题的特定代码块。请评论你认定为麻烦制造者的区块。@Dhyey好的,我照你说的做了。似乎返回错误;这是问题的根源。
:not([href="#modal-carousel"])
$('a[href*="#"]:not([href="#"])')