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