I am using the below line to blink a block. It works but the callback function incre()
is called immediately and does not wait till blinking is over.
I need to call incre()
only after the animate function blinks 2 seconds. What am I missing?
block.attr({ opacity: 0.3 }).animate({ opacity: 1 }, 2000,incre());
For what you are attempting fadeTo() sounds like a good choice
block.fadeTo(2000, 0.3, function() {
block.fadeTo(2000, 1);
});
However, the error in your codes are:
()
( Brackets after the callback function name) ie incre()
opacity
is a CSS property not an attribute. so user .css()
to manipulate them The correct codes are:
block
.css({ opacity: 0.3 })
.animate({ opacity: 1 }, 2000, incre);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.