JQuery-based floating DIV display prompt information and automatic hiding

Source: Internet
Author: User

Copy codeThe Code is as follows:
/**
* The floating DIV regularly displays prompt information, such as Operation success or failure.
* @ Param string tips (content prompted)
* @ Param int height the height of the information displayed from the top of the browser
* @ Param int the time displayed (in seconds), time> 0
* @ Sample <a href = "javascript: void (0);" onclick = "showTips ('Operation successful ', 100, 3);"> click </a>
* @ Sample the code above indicates that the operation is successfully clicked for 3 seconds, PX away from the top
* @ Copyright ZhouHr 2010-08-27
*/
Function showTips (tips, height, time ){
Var export wwidth = document.doc umentElement. clientWidth;
Var tipsDiv = '<div class = "tipsClass">' + tips + '</div> ';

$ ('Body'). append (tipsDiv );
$ ('Div. tipsClass 'examples .css ({
'Top': height + 'px ',
'Left': (required wwidth/2)-(tips. length * 13/2) + 'px ',
'Position': 'absolute ',
'Padding': '3px 5px ',
'Background': '# 8FBC8F ',
'Font-size': 12 + 'px ',
'Marggin': '0 auto ',
'Text-align ': 'center ',
'Width': 'auto ',
'Color': '# fff ',
'Opacity ': '0. 8'
}). Show ();
SetTimeout (function () {$ ('div. tipsClass '). fadeOut () ;}, (time * 1000 ));
}

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.