您的位置:首页 > Web前端 > JQuery

JQuery 浮动DIV显示提示信息并自动隐藏

2010-08-27 21:28 756 查看
自动记录, 以备忘记.....

 * @sample 上面代码表示点击后显示操作成功3秒钟, 距离顶部100px
* @Version V.1.0
* @copyright ZhouHr 2010-08-27
*/

function showTips( tips, height, time ){
var windowWidth  = document.documentElement.clientWidth;
var tipsDiv = '<div class="tipsClass">' + tips + '</div>';

$( '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 ) );
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: