• <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“悬停时"环形

      Javascript quot;while hoveredquot; loop(Javascript“悬停时环形)

        <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“悬停时"环形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href
                问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                Ordinals in words javascript(javascript中的序数)

                1. <legend id='PlXfa'><style id='PlXfa'><dir id='PlXfa'><q id='PlXfa'></q></dir></style></legend>
                  • <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>
                      <tbody id='PlXfa'></tbody>

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

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