alternate between two functions on click

前端 未结 2 1836
被撕碎了的回忆
被撕碎了的回忆 2021-01-20 19:37

How do I alternate between calling two functions on click? For example, here is the button

and here is the j

2条回答
  •  鱼传尺愫
    2021-01-20 20:20

    You can use the toggle pseudo-event:

    $('#fooButton').toggle(fooOne, fooTwo);
    

    Note: This is deprecated as of jQuery 1.8 and removed in jQuery 1.9+. You can use jQuery-migrate if you need this function anyway.

提交回复
热议问题