alternate between two functions on click

前端 未结 2 1856
被撕碎了的回忆
被撕碎了的回忆 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:17

    Use jQuery's toggle() method

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

    Edited to make use of your named functions rather than sloppily using anonymous ones.

提交回复
热议问题