Simulate Hover using jQuery

前端 未结 4 437
星月不相逢
星月不相逢 2020-12-19 04:03

Given the existing \"buttons\"

HTML:

 
      
4条回答
  •  一个人的身影
    2020-12-19 04:54

    #MB .list a:hover,
    #MB .list a:focus,
    #MB .list .active a {
      /* hover styles */
    }
    

    (I've simplified your selectors a bit, I would also suggest trying to remove the outer div as these are often unnecessary and the ul alone is enough)

    Javascript hover:

    function setHover() {
        if ($('#MB .list .active').next().length) {
            $('#MB .list .active').next().addClass('active').end().removeClass('active');
        } else {
            $('#MB .list .active').removeClass('active');
            $('#MB .list li:first-child').addClass('active');
        }
    }
    
    setInterval(setHover, 1000);
    

提交回复
热议问题