The details are as follows:
$ ('. Back_left dt '). Toggle (function () {
$ (this). AddClass ("selected");
$ (this). Siblings (' DD '). Slideup (),
},function () {
$ (this). Removeclass ("selected");
$ (this). Siblings (' DD '). Slidedown ();
Today in doing a project, copied someone else on the site of a code, found how can not be achieved, in my anxious not to do, think of the version of jquery is the problem? Then the jquery version down to 1.8, the function has been realized, my own version of the Jqurey is 1.11.1, the original version of the problem, the reason to find a good run, Baidu a bit, only to find the toggle method in the 1.9 version has been deleted. Changing the version can solve the problem, but I do not want to use the lower version, or want to use the 1.11.1 version, I would like to use what method instead of toggle?
After detection, you can use the following method instead:
$ (document). Ready (function () {
$ ('. Back_left DT '). Click (function () {
if ($ (this). Hasclass ("selected")) {
$ (this). Toggleclass ("selected");
$ (this). Siblings (' DD '). Slidedown ();
else{
$ (this). Toggleclass ("selected");
$ (this). Siblings (' DD '). Slideup ();}});
Parameters |
Description |
Speed |
Optional. Specify the speed (or vice versa) of the element from visible to hidden. The default is "0". Possible values:
- Milliseconds (for example, 1500)
- "Slow"
- "Normal"
- "Fast"
In the case of setting the speed, the element will gradually change its height, width, outer margin, inner margin, and transparency as it is visible to the hidden process. If you set this parameter, the switch parameter cannot be used. |
Callback |
Optional. The function to execute after the toggle function has finished executing. For more information on callback, please visit our JQuery callback chapter. This parameter cannot be set unless the speed parameter is set. |
Switch |
Optional. A Boolean value. Specify whether toggle hides or displays all selected elements.
- True-Displays all elements
- False-Hides all elements
If this parameter is set, the speed and callback parameters cannot be used. |