我们做网站,经常会遇到消息提示。

我仿照腾讯的邮箱做了个小demo。

提示出现后,几秒消失。提示的位置是固定的。不受布局的影响。

效果如下:

提示通常分两种,一种使错误提示,一种是成功提示。用不同的css已表示区分。

代码如下:

<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<script src="./js/jquery-1.4.2.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="./css/demo.css">
<script type="text/javascript">
$(document).ready(function(){
$("#message").click(function(){
showMsg('msg','success',);
}); $("#error").click(function(){
showMsg('errmsg','fail',);
});
});
function showMsg(msgtype,msgcontent,time){
$("#msgBoxDIV span").attr("class",msgtype).text(msgcontent); //获取提示信息并设置
$("#msgBoxDIV").show();
setTimeout(function () {
$("#msgBoxDIV").hide();
}, time);
} </script>
</head>
<div id="msgBoxDIV" style="position: absolute; width: 100%; padding-top: 2px; height: 24px; top: 43px; text-align: center; display: none;">
<span></span>
</div> <a class="btn_gray btn_space" hidefocus="" id="message" onclick="getTop();" href="javascript:;">提示消息</a> <a class="btn_gray btn_space" hidefocus="" id="error" href="javascript:;" name="del">提示错误</a> </html>

msgBoxDIV中的位置是固定死的,里面的span可以展示错误信息。

css样式如下:

.errmsg {
background: #ef8f00;
z-index: ;
} .msg {
background: #68af02;
z-index: ;
} .msg, .errmsg {
margin-left: 10px;
white-space: nowrap;
padding: 3px 24px 3px;
color: #fff;
height: 20px;
line-height: 18px;
border-radius: 3px;
}

js中主要用到:

$("#msgBoxDIV").show();
setTimeout(function () {
$("#msgBoxDIV").hide();
}, time);

显示,之后几秒再隐藏。就是这么个逻辑。

消息提示demo的更多相关文章

  1. 基于PNotify的消息提示Demo(轮询)

    需求:有些任务需要定时更新,获取最新的消息,这样就需要定时轮询,再者需要一种友好的提示. 以下就是使用PNotify插件的消息提示: 1.HTML代码 <!DOCTYPE html> &l ...

  2. 【C#】组件发布:MessageTip,轻快型消息提示窗

    -------------201610212046更新------------- 更新至2.0版,基本完全重写,重点: 改为基于原生LayeredWindow窗体和UpdateLayeredWindo ...

  3. jquery插件:仿百度首页可展开收起的消息提示控件

    消息提示插件大伙并不陌生了,无论是个系统还是网站,基本都要有消息系统.但我认为,一个好的提示插件应当具备很好的独立性,不与页面其他元素发生任何关系,其次是能对外提供丰富的接口,因为你生来就是被别人来调 ...

  4. 【Android代码片段之六】Toast工具类(实现带图片的Toast消息提示)

    转载请注明出处,原文网址:http://blog.csdn.net/m_changgong/article/details/6841266  作者:张燕广 实现的Toast工具类ToastUtil封装 ...

  5. 精美舒适的对话消息提示框--第三方开源--SweetAlertDialog

    SweetAlertDialog(sweet-alert-dialog)是一个套制作精美.动画效果出色生动的Android对话.消息提示框 SweetAlertDialog(sweet-alert-d ...

  6. 插件使用一顶部消息提示---overhang

    overhang 是一个非常好的消息提示插件,它是在顶部提示. 官方网站:https://github.com/paulkr/overhang.js 使用方法 1.引入jquery库和jqeury u ...

  7. 【WPF】屏幕右下角消息提示框

    WPF做一个仿QQ的右下角消息提示窗,网上找到几个Demo后,选了一个比较好用的. 博客 http://blog.csdn.net/huangli321456/article/details/5052 ...

  8. ymPrompt.js消息提示组件

    转载:https://www.cnblogs.com/linzheng/archive/2010/11/15/1878058.html 使用说明: 1.在页面中引入ymPrompt.js.如:< ...

  9. 【C#】无损转换Image为Icon 【C#】组件发布:MessageTip,轻快型消息提示窗 【C#】给无窗口的进程发送消息 【手记】WebBrowser响应页面中的blank开新窗口及window.close关闭本窗体 【手记】调用Process.EnterDebugMode引发异常:并非所有引用的特权或组都分配给呼叫方 【C#】DataRowState演变备忘

    [C#]无损转换Image为Icon 如题,市面上常见的方法是: var handle = bmp.GetHicon(); //得到图标句柄 return Icon.FromHandle(handle ...

随机推荐

  1. android学习精要

    第1章 初识android1.1 android平台概述1.2 android平台体系1.2.1 linux kernel内核层1.2.2 系统运行库libraries和android runtime ...

  2. ./configure : /bin/sh^M : bad interpreter

    用命令行来编译Qt的时候发生标题尚的错误. 原因是文件中带有DOS行结束符,必须把它转换成UNix结束符 references: http://stackoverflow.com/questions/ ...

  3. zend server 和zend studio安装

    zend server安装完后需要更改一个xml文件. 用记事本打开D:\Program Files\Zend\ZendServer\etc\ZendEnablerConf.xml文件. 将 锘??x ...

  4. UVA_埃及分数(Hard Version) UVA 12588

    Problem EEg[y]ptian Fractions (HARD version)Given a fraction a/b, write it as a sum of different Egy ...

  5. LeeCode-Delete Node in a Linked List

    Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...

  6. catkin_simple 的使用

    Catkin simple 可用于规范catkin package, 并简化CMakeLists  Dependencies are just listed once as build-depend  ...

  7. Unity 生命周期

    原文翻译:            Execution Order of Event Functions            事件函数的执行顺序                        Edit ...

  8. 高效CSS書寫規範及CSS兼容性

    一.選擇器針對性說明 某一元素的多个规则集中,选择器的针对性越高,该规则集的权重也就越高.针对性相同的,后出现的规则集的权重更高. * {} /* a=0 b=0 c=0 d=0 -> spec ...

  9. winform —— listview创建表及简单的增删改查

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  10. 输出jq对象

    console.log($()); 效果截图: