2026, 새로운 도약을 시작합니다.

tap안에서 swiper에 autoplay가 안됩니다

Copy




    window.addEventListener('load', function(){

    saleItemTab();

});

   function saleItemTab() {

    var saleItem = document.querySelector('.saleItem');

    if(!saleItem) return;

    var tabButtonList = saleItem.querySelectorAll('.menu > li > .button');

    tabButtonList.forEach(function(button) {

        button.addEventListener('click', handleClickButton);

        setTitle(button);

    });

    function handleClickButton(e) {

        var currentButton = e.target;

        tabButtonList.forEach(function(button) {

            button.classList.remove('active');

        });

        currentButton.classList.add('active');

        var contentId = currentButton.getAttribute('data-id');

        var currentContent = saleItem.querySelector('#' + contentId);

        var tabContentList = saleItem.querySelectorAll('.tabContent');

        tabContentList.forEach(function(content) {

            content.classList.remove('active');

        });

        currentContent.classList.add('active');

    }

    function setTitle(button) {

        var contentId = button.getAttribute('data-id');

        var targetContent = saleItem.querySelector('#' + contentId);

        var mainTitle = targetContent.querySelector('.mainTitle');

        var title = '';

        if (mainTitle) {

            title = mainTitle.textContent;

        }

        button.innerText = title;

    }

       swiper();//슬라이드 실행

}

    

    var swiper = new Swiper(".mySwiper", {

        slidesPerView: 1.5,

        spaceBetween: 2,

        loop: false,

        centeredSlides: true,

        loopFillGroupWithBlank: true,

        autoplay: {

          delay: 2500,

          disableOnInteraction: false,

          pauseOnMouseEnter: true,

        },

        observer: true, 

        observeParents: true,

      });



 

처음탭에서는 autoplay가 정상적으로 작동하는데 다른탭에서는 autoplay가 작동하지 않습니다. 다른건 다 적용됩니다.

고수님들 답을 알려주세요...ㅠㅠㅠㅠㅠ

답변 2개

크롬 등의 브라우저 정책상 영상 autoplay는 1개만 가능하세요. mute 설정한 후 해보시겠어요?

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

영상 넣을때 mute말씀하시는건가요? 이건 이미지 슬라이드라서요...

댓글을 작성하려면 로그인이 필요합니다.

F12 눌러서 id 충돌 되는거 있나 보세요.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

충돌되는 id는 없는거 같은데요... swiper는 같은 효과라서 class를 같게해서 써는데 다르게도 해서 적용했는데 안되네요....

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고