簡體   English   中英

簡單的jQuery滑塊腳本不起作用

[英]Simple jQuery slider script not working

我有一個簡單的jQuery滑塊,但無法在頁面上使用它的多個實例,我確信它是一個簡單的解決方法,但我的大腦只是不與atm合作

function testSlide() {
    var testAnim = document.querySelector(".testWrap");
    jQuery(".testWrap.animated ul img.dotNav").appendTo(jQuery('.testNav'));
    jQuery(".testWrap.animated ul > li:gt(0)").hide();
    jQuery(".testNav.animated > img.dotNav:gt(0)").addClass('inactivedot').removeClass('reddot');

    setInterval(function () {
        jQuery('.testWrap.animated ul > li:first')
            .stop(100)
            .fadeOut(100)
            .next()
            .fadeIn(100)
            .end();

        jQuery('.testWrap.animated ul > li:first').appendTo('.testWrap ul');
        jQuery('.testNav.animated> img:last-child')
            .prependTo('.testNav');


    }, 5000);
    jQuery(".testWrap").hover(function () {
        testAnim.classList.remove('animated');
    },

    function () {
        testAnim.classList.add('animated'); //Start the animation when mouse out
    });
}

任何幫助,將不勝感激

如果是的話,您可以將代碼轉換為jquery插件,以在頁面中創建滑塊的多個實例,這是我在Google上搜索到的鏈接:

https://learn.jquery.com/plugins/basic-plugin-creation/

暫無
暫無

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

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