簡體   English   中英

平滑滾動鏈接與fancybox沖突,將href更改為class還是id?

[英]Smooth Scrolling links conflicting w/ fancybox, change href to class or id?

我將其用於頂部和底部div之間的滾動過渡:

<script type="text/javascript">

$('a').on('click', function (event) {
    event.preventDefault();//stop the browser from jumping to the anchor
    var href  = $(this).attr('href'),
        oset  = $(href).offset().top;
    $('html, body').stop().animate({
        scrollTop : oset
    }, 1000, function () {
        location.hash = href;
    });
});

</script>

但這與我使用fancybox的方式(因為它使用的是“ href”)沖突,我嘗試在適當的位置定義“ div id”並創建共享類(例如,.smooth並在兩個鏈接中調用),但是它剛剛壞了。 我怎樣才能使用僅指定兩個div的規范?

從產生的問題-https: //stackoverflow.com/questions/8547378/fancybox-with-iframe-js-conflictions-with-my-site-wont-implement

更改此:

$('#menu a').on('click', function (event) {
    event.preventDefault();//stop the browser from jumping to the anchor
    var href  = $(this).attr('href'),
        oset  = $(href).offset().top;
    $('html, body').stop().animate({
        scrollTop : oset
    }, 1000, function () {
        location.hash = href;
    });
});

單擊“圖庫”並打開fancybox時,滾動沒有意義。

暫無
暫無

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

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