A simple fadeIn (fadeOut) Class _ javascript Technique

Source: Internet
Author: User
Recently, I found that forms used in the project are difficult to verify. I wrote one by myself while referring to other users. When an error is returned during verification, the prompt message uses the fadeIn (fadeOut) transition (because the browser's efficiency is too high, it will pop up at a moment ~~); You must be compatible with IE (element. style. filter = 'Alpha (opacity = value) ') and non-IE (element. style. opacity = value.
In addition, note that the value of non-IEopaciy is 0 ~ 1, IE is 1-100.

Below, paste the Code:

The Code is as follows:


/**
* @ ProjectDescription: Specifies the animation (Fade-in and fade-out) class.
*/**
* @ ProjectDescription KINGKIT UI
* @ Date 2010-6-1
* @ Author Kit. Liao
* @ Copyright kingkit.com.cn
* @ Version 0.9.0
* @ Thanks: http://www.cnblogs.com/rubylouvre/archive/2009/09/16/1566699.html
* Example: fade-in: KUI. Animation. fadeIn (el); fade-in: KUI. Animation. fadeOut (el)
*/
KUI. Animation = {
FadeIn: function (id ){
This. fade (id, true );
},
FadeOut: function (id ){
This. fade (id, false );
},
Fade: function (id, flag ){
Var target = KUI. get (id );
Target. alpha = flag? ;
Target. style. opacity = (target. alpha/100 );
Target. style. filter = 'Alpha (opacity = '+ target. alpha + ')';
Var value = target. alpha;
(Function (){
Target. style. opacity = (value/1, 100 );
Target. style. filter = 'Alpha (opacity = '+ value + ')';
If (flag ){
Value ++;
If (value <= 100 ){
SetTimeout (arguments. callee, 15); // continue to call itself
}
}
Else {
Value --;
If (value> = 0 ){
SetTimeout (arguments. callee, 15); // continue to call itself
}
}
})();
}
}


Package download
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.