There were very few things learned yesterday, and some things were delayed. It was good today, And it entered the State in the morning. Although it was a bit cold, there was a catch of cold.
SlideToggle (speed, [callback]) in the sliding effect
Speed: Three predefined speeds ("slow", "normal", "fast") and millisecond values (for example, 1000) that indicate the animation duration)
[Callback] function executed when the animation is completed
Example:
Html: <p> This is the dddddddddddddddddddd used for testing. <br/>
Dddddddddddddddddddddddddddddddddddd <br/>
Ddddd </p>
$ (Document). ready (function (){
$ ("P"). slideToggle ("fast", function (){
Alert ("Animation Done .");
});
});
After reading it in the browser, it worked, and the line quickly slipped and disappeared.
If you add a style for this P label, style = "display: none", then this section will appear slowly, rather than disappear.
This disappears for no reason, and it is not very good. I suddenly remembered that I saw a bind () method yesterday and bound an event handler function to the element,
You can also use it to modify this method. Well, the effect is fine.
$ (Document). ready (function (){
$ ("P"). bind ("click", function (){
$ (This). slideToggle ("fast", function (){
Alert ("Animation Done .");
});
});
});
You can add a style without adding it. In short, this method is used.
Bind method details: bind an event processor function to a specific event (such as click) that matches each element.
This event handler receives an event object, which can be used to prevent (browser) default behavior. If
To cancel the default action and prevent event bubbles, the event handler function must return false.
Usage 1: The time processing function can be defined as an anonymous function.
$ ("P"). bind ("click", function (){
$ (This). slideToggle ("fast", function (){
Alert ("Animation Done .");
});
});
Usage 2: If an anonymous function cannot be defined, an optional data object can be passed as the second parameter, and the event processing function becomes the third parameter.
Function handler (event ){
Alert (event. data. foo );
}
$ ("P"). bind ("click", {foo: "bar"}, handler)
In fact, this bind method can cancel the default browser behavior and prevent event bubbles, because these two are not very familiar with, so do not write how
To solve these two problems, I plan to first check the browser's default behavior and event bubbles ......