Click toggle with jquery/javascript

前端 未结 5 2058
粉色の甜心
粉色の甜心 2021-01-07 13:17

I want to click a table element and to have it do x the first click and if clicked again perform Y

         


        
5条回答
  •  执念已碎
    2021-01-07 13:40

    demo: http://jsfiddle.net/HJwJf/

    Link the toggle method with;

     $("button").toggle(function(){
        $("body").css("background-color","green");},
        function(){
        $("body").css("background-color","red");},
        function(){
        $("body").css("background-color","yellow");}
      );
    

提交回复
热议问题