jQuery UI switchClass() method is not working properly

后端 未结 7 2210
野的像风
野的像风 2020-12-11 15:43

jQuery UI switchClass() method doesn\'t switch class, rather it performs some undesired animations and the class remains the same as the original one when I use

7条回答
  •  余生分开走
    2020-12-11 16:21

    $(function(){
       $('#circle').click(function(){
          $('.circle').switchClass('circle', 'square', 'slow');
          $('.square').switchClass('square', 'circle', 'slow');
          return: false
       });  
    });
    

    In this Example on the click of the #circle Div I am removing the .circle class from all objects and replacing it with the .square class. If the .circle class is not there to be removed then the .square class is removed and replaced with the .circle class. It is a toggle effect.

    If you do no want the toggle just remove the top or bottom one.

提交回复
热议问题