• <bdo id='hyNRP'></bdo><ul id='hyNRP'></ul>
    1. <small id='hyNRP'></small><noframes id='hyNRP'>

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

      Javascript“悬停时"环形

      时间:2023-11-29

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

                <tbody id='ZIcYx'></tbody>

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

                本文介绍了Javascript“悬停时"环形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                谁能帮我解决这个问题...我有一个按钮,当它悬停时会触发一个动作.但只要按钮悬停,我希望它一直重复.

                Can anybody help me on this one...I have a button which when is hovered, triggers an action. But I'd like it to repeat it for as long as the button is hovered.

                我很感激任何解决方案,无论是在 jquery 还是纯 javascript 中 - 这是我的代码此时的样子(在 jquery 中):

                I'd appreciate any solution, be it in jquery or pure javascript - here is how my code looks at this moment (in jquery):

                var scrollingposition = 0;
                
                $('#button').hover(function(){
                ++scrollingposition;
                    $('#object').css("right", scrollingposition);
                    });
                

                现在我怎样才能把它放到某种while循环中,以便#object在#button悬停时逐像素移动,而不仅仅是当鼠标进入它时?

                Now how can i put this into some kind of while loop, so that #object is moving px by px for as #button is hovered, not just when the mouse enters it?

                推荐答案

                好的……又是一个答案:

                OK... another stab at the answer:

                $('myselector').each(function () {
                  var hovered = false;
                  var loop = window.setInterval(function () {
                    if (hovered) {
                      // ...
                    }
                  }, 250);
                
                  $(this).hover(
                    function () {
                      hovered = true;
                    },
                    function () {
                      hovered = false;
                    }
                  );
                });
                

                250 表示任务每四分之一秒重复一次.您可以减少此数字以使其更快,或增加它以使其更慢.

                The 250 means the task repeats every quarter of a second. You can decrease this number to make it faster or increase it to make it slower.

                这篇关于Javascript“悬停时"环形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:CSS 变换 - 保持悬停状态的价值 下一篇:JQuery .slideDown() 向上滑动

                相关文章

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

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

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