Sunday 15 September 2013

javascript - Plus sign not changing back -


I have a simple toggle script that looks like this:

When the page starts at < Code> + is shown, and when the change in a - has been toggled, but once again clicked, +

does not change back, why does not this work? If the element is visible when I am I / A, then when #If the given bioincine does not appear, then it should be changed back to +.

Here is Jquery: $ ("# Showmore") click on (function () {$ ("# hidden more") SlideToggle (200); $ ("# hidden" $ (":") "$" ("Show"). Text ("more"): $ ("# showmore"). Text ("plus +");});});

You have to put it under a callback for the slide prompt, because it is not guaranteed Element view check is executed after the animation is completed:

  $ ("# showMore"). Click (function () ($ ("# hidden More") SlideToggles (200, function (text ("more -"): $ ("# showmore"). Text ("plus +")}} {$ (This): "$ (this)." (":") "$" ("# Showmore").});   

Full of animation You can also try this by using the function of callback to swap text when you swap the text:

  $ (task () {$ ("# showmore") click (Function () {var $ this = $ (this); $ ("# hiddenmore") SlideToggle (200, function) ($ $ this.text (function (_, text) {return text == "more -" ? "Plus +": "more -";});});});});   



No comments:

Post a Comment