簡體   English   中英

內部滾動干擾boostrap傳送帶

[英]Internal scroll interfers with boostrap carousel

我在一個也實現了Bootstrap輪播的網站上有一個本地滾動腳本(單擊鏈接可將您帶到頁面的另一部分)。

內部滾動腳本似乎覆蓋了輪播腳本,並且不確定如何修復。 我嘗試利用jQuery的:not()方法,但無法使其按我需要的方式工作。

網站正在開發中

JS

$('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') === this.pathname.replace(/^\//,'') && location.hostname === this.hostname) {
        var target = $(this.hash);
        target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
        if (target.length) {
            $('html,body').animate({
                scrollTop: target.offset().top
            }, 800);
            return false;
        }
    }

嘗試:not(a[role="button"] ,如下所示:

$('a[href*=#]:not(a[role="button"])').click(function() {
    if (location.pathname.replace(/^\//,'') === this.pathname.replace(/^\//,'') && location.hostname === this.hostname) {
        var target = $(this.hash);
        target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
        if (target.length) {
            $('html,body').animate({
                scrollTop: target.offset().top
            }, 800);
            return false;
        }
    }
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM