When I recently wrote an instance, I used the Toggle function, but when the call is called, the element will be hidden. It has been used before using multiple events to switch. Bachelon is not allowed to search for the jQuery API document on the Internet. The reason was finally found:
It turned out that after the jQuery 1.9 version, Toggle () changed. The following is the Notes of the official website:
Note: This Method Signature was setted in jquery 1.8 and Removed in jQuery 1.9. Jquery Also PROVIDES An Animation MethodNamed .toggle () That Toggles the VIS IBILITY of Elements. WHETHER the Animation or The Event Method is Fired Depends on the SET of ArgumentsPassed.
In the early version, there were two toggle () with the same name, but the method of executing was different:
.toggle (Handler (eventObject), Handler (eventObject) [, handler (eventObject)])
Description: Bind Two or Morers to the Matched Elements, to Be Executed on Alternate Clicks.
=========================================== ===
.toggle ([Duration] [, Complete])
Descripting: Display or Hide the Matched Elements.
The subsequent version removed the first Toggle () function, which caused the element to hide the element when it was used to call the switching function.
======================
Now that this function is removed, the demand is still required. How to achieve turns switching of multiple events?
Different functions can be performed by judging different situations by the click event, or different functions are performed by setting a variable count.
Copy code code as follows:
var num = 0;
$ ('#Button'). CLICK (Function (E) {
if (num ++ %2 == 0) {{
// dosomething
} Else {
// Doothersomething
}
e.preventdefault (); // Prevent the default action of the element (if existence)
});