• <small id='Ke5Qm'></small><noframes id='Ke5Qm'>

  • <legend id='Ke5Qm'><style id='Ke5Qm'><dir id='Ke5Qm'><q id='Ke5Qm'></q></dir></style></legend>
      <bdo id='Ke5Qm'></bdo><ul id='Ke5Qm'></ul>

  • <tfoot id='Ke5Qm'></tfoot>
    <i id='Ke5Qm'><tr id='Ke5Qm'><dt id='Ke5Qm'><q id='Ke5Qm'><span id='Ke5Qm'><b id='Ke5Qm'><form id='Ke5Qm'><ins id='Ke5Qm'></ins><ul id='Ke5Qm'></ul><sub id='Ke5Qm'></sub></form><legend id='Ke5Qm'></legend><bdo id='Ke5Qm'><pre id='Ke5Qm'><center id='Ke5Qm'></center></pre></bdo></b><th id='Ke5Qm'></th></span></q></dt></tr></i><div id='Ke5Qm'><tfoot id='Ke5Qm'></tfoot><dl id='Ke5Qm'><fieldset id='Ke5Qm'></fieldset></dl></div>

        使用 jQuery 模拟悬停

        时间:2023-11-29
        <legend id='I9PgQ'><style id='I9PgQ'><dir id='I9PgQ'><q id='I9PgQ'></q></dir></style></legend>
            <tbody id='I9PgQ'></tbody>
          • <i id='I9PgQ'><tr id='I9PgQ'><dt id='I9PgQ'><q id='I9PgQ'><span id='I9PgQ'><b id='I9PgQ'><form id='I9PgQ'><ins id='I9PgQ'></ins><ul id='I9PgQ'></ul><sub id='I9PgQ'></sub></form><legend id='I9PgQ'></legend><bdo id='I9PgQ'><pre id='I9PgQ'><center id='I9PgQ'></center></pre></bdo></b><th id='I9PgQ'></th></span></q></dt></tr></i><div id='I9PgQ'><tfoot id='I9PgQ'></tfoot><dl id='I9PgQ'><fieldset id='I9PgQ'></fieldset></dl></div>

                • <bdo id='I9PgQ'></bdo><ul id='I9PgQ'></ul>

                  <small id='I9PgQ'></small><noframes id='I9PgQ'>

                • <tfoot id='I9PgQ'></tfoot>
                • 本文介绍了使用 jQuery 模拟悬停的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  鉴于现有的按钮"

                  HTML:

                   <div id="MB">
                      <ul class="list">
                         <li id="post-5"><a href="#post-5">5</a></li>
                         <li id="post-4"><a href="#post-4">4</a></li>
                         <li id="post-3"><a href="#post-3">3</a></li>
                         <li id="post-2"><a href="#post-2">2</a></li>
                         <li id="post-1"><a href="#post-1">1</a></li>
                      </ul> 
                   </div>
                  

                  CSS:

                    #MB .list li a {
                          float:left;
                          color:#333;
                          background:#f6f6f6;
                          border:1px solid #eaeaea;
                          border-right:none;
                          padding:0 8px;
                          }
                  
                     #MB .list li a:hover,
                     #MB .list li a:focus {
                          color:#fff;
                          border:1px solid #333333;
                          border-right:none;
                          background:#404040;
                          text-decoration:none;
                          }
                  

                  我想每隔 n 秒按顺序在每个按钮上自动模拟悬停".

                  I'd like to simulate "hover" automatically on each button, sequentially, every n seconds.

                  这意味着每 n 秒一个按钮悬停"(改变颜色等),在下一个间隔关闭",下面的按钮将打开"等等......

                  This means that every n seconds a button is "hovered" (changing color etc), at next interval is "turned off" and the following button will "turn on" and so on...

                  推荐答案

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

                  (我已经稍微简化了您的选择器,我还建议尝试删除外部 div 因为这些通常是不必要的,单独的 ul 就足够了)

                  (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 悬停:

                  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);
                  

                  这篇关于使用 jQuery 模拟悬停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 CSS 中的悬停覆盖图像上 下一篇:Internet Explorer:当目标 DOM 元素在 DOM 中移动时,悬停状态变为粘滞状态

                  相关文章

                    1. <tfoot id='a33ll'></tfoot>
                      • <bdo id='a33ll'></bdo><ul id='a33ll'></ul>

                      <legend id='a33ll'><style id='a33ll'><dir id='a33ll'><q id='a33ll'></q></dir></style></legend>

                      <small id='a33ll'></small><noframes id='a33ll'>

                    2. <i id='a33ll'><tr id='a33ll'><dt id='a33ll'><q id='a33ll'><span id='a33ll'><b id='a33ll'><form id='a33ll'><ins id='a33ll'></ins><ul id='a33ll'></ul><sub id='a33ll'></sub></form><legend id='a33ll'></legend><bdo id='a33ll'><pre id='a33ll'><center id='a33ll'></center></pre></bdo></b><th id='a33ll'></th></span></q></dt></tr></i><div id='a33ll'><tfoot id='a33ll'></tfoot><dl id='a33ll'><fieldset id='a33ll'></fieldset></dl></div>