Page element binding jquery toggle after element hiding solution

  • 2020-03-30 02:29:44
  • OfStack

It has been more than a month since I started my internship. The company assigned me very few tasks, which made me feel a little uncomfortable. In that case, I still have something to do, to write the graduation project. Anyway, when I was writing my graduation project today, a miracle happened after I bound an element to jquery's toggle method, and all the elements bound to this method were hidden. At the beginning, I never thought that there was a problem here, but it took me a long time to find out that it was because of binding the toggle method. But why is the element hidden after binding the method?

In fact, I do not know the specific reason, I found through the search information, the original jquery after the 1.9 version of the function has changed, no longer support for multiple events in turn switch, did half a day is the original version of the problem. There are therefore two solutions, and they are the only two that have been thought of so far:

1. Switch to a slightly lower version of jquery
2. If you don't want to switch to a lower version of jquery, you can do so with counters. This means that you define a global variable in js that keeps track of how many times the element that you want to bind to is clicked to get the same effect.

Ah, unexpectedly encounter such problem, silent mourning...

Related articles: