Why does this jquery slideToggle code not work? -


I'm trying to change the button text for the extension / collapse button basically, on a user "abbreviate" Clicks and I toggles the slide and when sloglogged, I change the button text to "expand" and vice versa.

The following code works very well, though you click

any suggestions are appreciated.

Thank you! Thanks! Thanks! Thanks! ($ (Box) .is (": hidden")) {$ (box) Slide Toggle ("slow", function () {$ (button)

function toggle (button, box) .html ("compress");}); } And {$ (.x) .slideToggle ("slow", function () {$ (button) .html ("expand");}); }}

In your case, it will be safer to check because you're setting the animation ending Such as:

  function togglebox (button, box) {$ (box). SlogToggle ("slow", function () {text}  $ (button) .HTML ($ (this) .is (": hidden")? "Expand": "collapse");}) ; }  

Currently you are checking on the start, but remember that this is not : hidden as long as it does not end Hides, the moment slideup is complete, it is still : visible :)


Comments