admin管理员组文章数量:1291582
I have the following JQuery code
$("#classparent").click(function () {
$(".classsubitems").slideToggle('slow', function () {
});
});
I need to let JQuery run some code at begin and end of animation.
Is this possible?
Thank you
I have the following JQuery code
$("#classparent").click(function () {
$(".classsubitems").slideToggle('slow', function () {
});
});
I need to let JQuery run some code at begin and end of animation.
Is this possible?
Thank you
Share Improve this question asked Oct 31, 2011 at 13:42 OzkanOzkan 2,0416 gold badges29 silver badges43 bronze badges4 Answers
Reset to default 6Simple enough.
$("#classparent").click(function () {
// before start of animation code here
$(".classsubitems").slideToggle('slow', function () {
// end of animation code here in the callback
});
});
The code you want to execute before the animation you can place before the slideToggle method. The code you want to execute after the animation you can place in the callback function.
SlideToggle has a callback-function (it looks like you already have provided that?)
http://api.jquery./slideToggle/
For the code to be executed before the animation: the easies way to do this is simply calling it before the line with $(".classsubitems")
.
SlideToggle doesn't have callback method to call at the beggining but it is possible when pletes.
$("#classparent").click(function () {
//Code to call before animation starts
$(".classsubitems").slideToggle('slow', function () {
//code to execute after the animation finish.
}); });
本文标签: javascriptjquery do something at the begin and end of animationStack Overflow
版权声明:本文标题:javascript - jquery do something at the begin and end of animation - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741536193a2384040.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论