I am trying to change the button text for the expand / collapse button. Basically, the user clicks "Minimize" and I execute the slideToggle function, and when the slideToggle method is executed, I change the button text to "Expand" and vice versa.
The following code works fine if you quickly click on the expand / collapse button, it loses its mind and shows “Expand” when it is already deployed, or “Collapse” when it has already collapsed.
Any advice is appreciated.
Thanks!
toggleBox function (button, field) {if ($ (box) .is (": hidden")) {$ (box) .slideToggle ("slow", function () {$ (Button) .html ("Collapse") ;}); } else {$ (box) .slideToggle ("slow", function () {$ (Button) .html ("Expand");}); }}
source share