Just write the code
accurately; and you will achieve the desired effect. Here is the hint: either use
toggleClass
along or
addClass/removeClass
without
toggle
.
Read more carefully:
http://api.jquery.com/toggleClass/[
^],
http://api.jquery.com/addClass/[
^],
http://api.jquery.com/removeClass/[
^].
The function
.toogle()
is unrelated to CSS classes; it just displays and hides the element:
http://api.jquery.com/toggle[
^].
Now think about it: if some content is hidden, what's the use of changing its CSS class? The opposite makes sense: you can change the class, and the CSS classes may have different
visibility
. But what you are trying to do makes no sense.
—SA