/*
*提示插件
*使用方法:showTip('提示內容',3)
*/
var tip = null;
//顯示提示文本,text爲要顯示的文本,second表示自動消失的秒數
function showTip(text,second){
if(!tip){
tip = document.createElement('div');
tip.style.backgroundColor = '#000';
tip.style.color = '#fff';
tip.style.fontSize = '18px';
tip.style.fontWeight = 'bold';
tip.style.fontFamily = '微軟雅黑';
tip.style.width = 'auto';
tip.style.height = 'auto';
tip.style.padding = '10px 30px 10px 30px';
tip.style.borderRadius = '6px';
tip.style.opacity = '0.7';
tip.style.position = 'fixed';
tip.style.zIndex = '99999';
document.body.appendChild(tip);
}
tip.innerHTML = text;
tip.style.display = 'inline-block';
tip.style.top = (document.documentElement.clientHeight/2 - tip.offsetHeight/2) + 'px';
tip.style.left = (document.documentElement.clientWidth/2 - tip.offsetWidth/2) + 'px';
setTimeout(function disappear(){
tip.style.display = 'none';
},second*1000);
}
js提示小插件
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.