JQuery Toggle Substitution Method _jquery

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.