JQuery toggle, instead of jquerytoggle

Source: Internet
Author: User

JQuery toggle, instead of jquerytoggle

The specific content is as follows:

$('.back_left dt').toggle(function(){$(this).addClass("selected");$(this).siblings('dd').slideUp();},function(){$(this).removeClass("selected");$(this).siblings('dd').slideDown();}); 

Today, I was working on a project, copied a code from someone else's website, and found that it could not be implemented. When I was so anxious to try again, I thought about whether it was a jquery version problem? Later, I reduced jquery version to 1.8 and implemented the function. My own jqurey version was 1.11.1. It turned out to be a version problem. It was easy to solve the problem after I found it. Baidu just clicked on it, the toggle method was deleted in version 1.9. A new version can solve the problem, but I don't want to use a lower version. I still want to use version 1.11.1. What method should I use to replace 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. Specifies the speed (or opposite) of the element from visible to hidden ). The default value is "0 ".

Possible values:

  • Millisecond (e.g. 1500)
  • "Slow"
  • "Normal"
  • "Fast"

When you set the speed, the height, width, margin, padding, and transparency of an element gradually change from visible to hidden.

If this parameter is set, the switch Parameter cannot be used.

Callback

Optional. The function to be executed after the toggle function is executed.

To learn more about callback, visit our jQuery Callback chapter.

This parameter cannot be set unless the speed parameter is set.

Switch

Optional. Boolean value. Specifies whether toggle hides or displays all selected elements.

  • True-show all elements
  • False-hide all elements

If this parameter is set, the speed and callback parameters cannot be used.

Articles you may be interested in:
  • JQuery toggle () sets CSS styles
  • JQuery toggle Usage Analysis
  • Program segments equivalent to toggleClass in jQuery and future learning directions
  • JQuery effect slideToggle () method (switch between hide and display)
  • Getting started with JQuery -- Introduction to toggle () method for event Switching
  • The jQuery method is simple to implement the use of the line color replacement and toggleClass.
  • Example of using the toggle method of the alternate Click Event in jquery
  • Use JQuery toggle to implement automatic pop-up of webpage Loading
  • Solution to element hiding after jquery toggle is bound to the page Element

Related Article

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.