Home > Web Front-end > JS Tutorial > body text

JQuery floating DIV prompt information and automatically hide the code_jquery

WBOY
Release: 2016-05-16 18:20:34
Original
947 people have browsed it
复制代码 代码如下:

/**
* Floating DIV regularly displays prompt information, such as operation success, failure, etc.
* @param string tips (content of the tip)
* @param int height The height of the displayed information from the top of the browser
* @param int time displayed time (in seconds), time > 0
* @sample Click
* @sample The above code indicates that the operation is successful for 3 seconds after clicking, 100px from the top
* @copyright ZhouHr 2010-08-27
*/
function showTips( tips, height, time ){
var windowWidth = document.documentElement.clientWidth;
var tipsDiv = '
' tips '
';

$( 'body' ).append( tipsDiv );
$( 'div.tipsClass' ).css({
'top' : height 'px',
'left' : ( windowWidth / 2 ) - ( tips.length * 13 / 2 ) 'px',
'position' : 'absolute',
'padding' : '3px 5px',
'background': '#8FBC8F',
'font-size' : 12 'px',
'margin' : '0 auto',
'text-align': 'center',
'width' : 'auto',
'color' : '#fff',
'opacity' : '0.8'
}).show();
setTimeout( function(){$( 'div.tipsClass' ).fadeOut();}, ( time * 1000 ) );
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template