开发者

How can i restart toggle when another button is clicked?

i have 2 buttons each of them has toggle fun开发者_如何学编程ction with 2 function inside the toggle. i have a problem that i want the toggle to be restarted if the user didn't click on the same button twice for example

if the user clicks on X first function will fires if he clicks on Y and then re-click on X the first function will fires again. but if he clicks on X first function will fires and he clicks on X again then the second function will fires.

$('x').toggle(
   function(){
     //something
   },
   function(){
     //something
   }
}

$('y').toggle(
   function(){
     //something
   },
   function(){
     //something
   }
}

please tell me your opinions and if there is a solution better than toggle ... please tell me


Don't use .toggle, as it won't provide you with what you need. Make something custom instead, giving the "x" button state (and changes to the state execute your functions) which can be modified by the "y" button.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜