• <tfoot id='4I0y9'></tfoot>

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

          <bdo id='4I0y9'></bdo><ul id='4I0y9'></ul>

        <small id='4I0y9'></small><noframes id='4I0y9'>

        <legend id='4I0y9'><style id='4I0y9'><dir id='4I0y9'><q id='4I0y9'></q></dir></style></legend>

        jQuery:在点击功能上切换旋转 div

        时间:2023-10-13

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

          <tbody id='UMO5o'></tbody>

              <legend id='UMO5o'><style id='UMO5o'><dir id='UMO5o'><q id='UMO5o'></q></dir></style></legend>
              • <bdo id='UMO5o'></bdo><ul id='UMO5o'></ul>
              • <tfoot id='UMO5o'></tfoot>
              • <i id='UMO5o'><tr id='UMO5o'><dt id='UMO5o'><q id='UMO5o'><span id='UMO5o'><b id='UMO5o'><form id='UMO5o'><ins id='UMO5o'></ins><ul id='UMO5o'></ul><sub id='UMO5o'></sub></form><legend id='UMO5o'></legend><bdo id='UMO5o'><pre id='UMO5o'><center id='UMO5o'></center></pre></bdo></b><th id='UMO5o'></th></span></q></dt></tr></i><div id='UMO5o'><tfoot id='UMO5o'></tfoot><dl id='UMO5o'><fieldset id='UMO5o'></fieldset></dl></div>
                  本文介绍了jQuery:在点击功能上切换旋转 div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试确定是否可以在单击功能上切换 div 的旋转,例如单击菜单按钮可将箭头从向下旋转到向上,再次单击将反转(从上到下).

                  我有一个 jsfiddle 演示设置,它会更有意义:http://jsfiddle.net/bf7Ke/1/
                  jQuery —

                  I'm trying to work out if it's possible to toggle the rotation of a div on a click function, e.g. Clicking on a menu button rotates the arrow from pointing downwards to upwards and clicking again will reverse this (upwards to downwards).

                  I have a jsfiddle demo setup which will make more sense of it: http://jsfiddle.net/bf7Ke/1/
                  jQuery —

                  $(document).ready(function(){
                          $('.menu-category-title').click(function(){
                                $('#menu-'+$(this).attr('hook')).fadeToggle('slow');
                                $(this).children('.menu-title-arrow').rotate({animateTo:180});
                  
                          return false;
                      });
                  });
                  

                  到目前为止,单击 .menu-category-title 会淡入下面的相关内容并将相应的箭头旋转 180 度.再次单击 .menu-category-title 会淡出相关内容,但箭头保持在 180 度.无论如何也可以切换此功能?
                  我无法弄清楚,任何建议将不胜感激!

                  Thus far clicking on .menu-category-title fades in the relevant content below and rotates the corresponding arrow by 180 degrees. Clicking .menu-category-title again fades out the relevant content but the arrow stays at 180 degrees. Is there anyway to toggle this function also?
                  I can't figure it out, any suggestions would be greatly appreciated!

                  推荐答案

                  认为你应该在箭头旋转之前检查元素是否可见

                  Think you should check if element is visible or not before arrow rotation

                  $(document).ready(function(){
                      $('.menu-category-title').click(function(){
                          var elem = $('#menu-'+$(this).attr('hook')),
                              arrow = $(this).children('.menu-title-arrow')
                  
                          if (!elem.is(':visible'))  {
                              arrow.rotate({animateTo:180});
                          } else {
                              arrow.rotate({animateTo:360});
                          }
                          elem.fadeToggle('slow', function() {
                          });
                  
                      return false;
                     });
                  });
                  

                  http://jsfiddle.net/bf7Ke/2/

                  这篇关于jQuery:在点击功能上切换旋转 div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在鼠标移动事件后围绕其中心旋转 Canvas 对象 下一篇:如何在画布中旋转一张图像?

                  相关文章

                  最新文章

                • <legend id='x0zQi'><style id='x0zQi'><dir id='x0zQi'><q id='x0zQi'></q></dir></style></legend>
                    • <bdo id='x0zQi'></bdo><ul id='x0zQi'></ul>
                  1. <tfoot id='x0zQi'></tfoot>

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

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