我在代碼中使用 intro.js 來實作演練。我想實作一個Sceanrio,當點擊完成按鈕(.introjs-donebutton)時,頁面應該滾動到頂部,但在這個代碼中,它沒有發生。誰能幫我解決這個問題呢?
。//$('.col-new-four').attr('id','essentials') ;
const intro = introJs();
intro.setOptions( {
steps:[
{
element:'#featured_apps_2_0'/span>,
intro:'welcome'.
},
{
element:'#myTopnav'/span>。
intro:'快速訪問你需要的應用程式和門戶網站'。
},
{
element:'.slideshow-container'/span>,
intro:'這個空間有你最關心的話題。'。
},
{
element:'.card'/span>,
intro:'保持最新的趨勢故事'。
},
{
element:'#stepextra'/span>,
intro:'查看你的推薦和喜愛的頁面'。
},
{
element:'#step4'/span>,
intro:'在這里尋找促銷內容、最新的補充內容和更多。
},
{
element:'#essentials2'/span>,
intro:'了解你喜歡的話題的趨勢'。
},
{
element:'.col-new-7525'/span>,
intro:'探索為你提供的好處、工具和新功能'。
}
]
})
$('.introjs-donebutton').click(function() {
$(window).scrollTop(0)。
});
function callintro(){
intro.start()。
console.log(" called intro")
}
<script src="https://ajax. googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">< /script>
<script src="https://cdnjs.cloudflare. com/ajax/libs/intro.js/4.2.2/intro.min.js"></script>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" class="snippet-box-edit snippet-box-result" frameborder="0"></iframe>
uj5u.com熱心網友回復:
我假設你想在點擊一個按鈕時將客戶視圖頁面滾動到頂部。如果是這樣,你可以使用這段代碼
HTML<div class="button-parent"/span>>
< button type="button" class="button-top" > 點擊這里</button>
</div>
jQuery
$(document).ready(function () {
$('.button-to-top').on('click',function () {
$('body').scrollTop(0)。
});
});
不要忘記在你的html頭檔案中添加jQuery cdns。如果它不作業,請分享你的HTML代碼。我們將期待
uj5u.com熱心網友回復:使用純javascript,沒有框架
window.scrollTo({ top。0, behavior: 's smooth' })
uj5u.com熱心網友回復:
所以我用了這個,它開始運行得很好,原因是按鈕是在最初的頁面加載后動態創建的,所以這應該是有效的
。 $(document) 。 on("click", ".introjs-donebutton", function(){
$(document).scrollTop(0)。
})
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/320706.html
標籤:
