博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
点击HTML页面问号出现提示框
阅读量:7055 次
发布时间:2019-06-28

本文共 3792 字,大约阅读时间需要 12 分钟。


本demo的功能:点击页面按钮在其边缘出现提示信息,点击页面任何一处则消失。

如下图:

1045988-20190122205743290-265924278.png

1.所需插件:

  • jquery插件;
  • layer插件;

2.HTML内容:

==注意==:

  1. class="j-help-tips"这个class是核心,不可缺少。
  2. data-tips属性是必须的。
  3. data-tips属性中:type:"1"不用修改;
  4. data-tips属性中:txt内容即是要提示的内容。
            

3.css内容:(非必要)

  • 本demo的css非必须,不影响功能;
.edi-icon {    font-size: 18px;    font-style: normal;    -webkit-font-smoothing: antialiased;    -webkit-text-stroke-width: .2px;    -moz-osx-font-smoothing: grayscale;    *display: inline;    *zoom: 1;    cursor: pointer;}

4.javascript内容:(核心)

//定义提示弹出框;var helpTipsLayer;//定义弹出框的默认设置;function helpTips(t) {    this.options = {},     this.options.elem = ".j-help-tips", //与页面class相对应;    this.options.type = 1,     this.options.color = "#8db3d7",     this.options.time = 0, //设置0是提示弹出框不会自动消失;可设置为其他数字,以毫秒为单位;    this.options.titleEnd = "录入提示",     this.options.width = "600px",     this.options.height = "",     this.options.imgWidth = "233",     this.options.imgHeight = "375",     "undefined" != typeof t && (this.options = $.extend({}, this.options, t)),     this.elemObj = $(this.options.elem)}!function() {    //点击页面任何一处可使提示弹出框消失;    $(document).on("click", function(event){        var e = event || window.event;        var target = e.target || e.srcElement;        var flag = $(target).hasClass("j-help-tips");        if(helpTipsLayer && !flag){            layer.close(helpTipsLayer);        }    })}(), helpTips.prototype = {    constructor : helpTips,    init : function() {        this.bindEvent()    },    bindEvent : function() {        var t = this;        t.elemObj.on("click", function() {            layer.close(helpTipsLayer);//点击其他任意的提示框按钮,则关闭上一个提示框。            var i = $(this),                o = i.data("tips");            if ("undefined" != typeof o && "undefined" != typeof o.type && 1 == o.type) {                "undefined" != typeof o && "undefined" != typeof o.txt ? helpTipsLayer = layer.tips(o.txt, i, {                    tips : [ t.options.type, t.options.color ],                    time : t.options.time                }) : t.log()            } else {                if ("undefined" != typeof o.title && "undefined" != typeof o.txt && "undefined" != typeof o.img) {                    var e = '
', n = '

' + o.title + t.options.titleEnd + '

', s = "
", l = '
    ', p = o.txt.split("|"), a = p.length; a > 0 && $.each(p, function(t, i) { l += '
  • ' + (t + 1) + "" + i + "
  • " }); var r = /^[1-9][\d]{0,2}$/, c = t.options.imgWidth, d = t.options.imgHeight; "undefined" != typeof o.w && "undefined" != typeof o.h && r.test(o.w) && r.test(o.h) && (c = o.w, d = o.h), l += '
  • ' + (a + 1) + "
  • ', l += "
"; var h = e + n + l + s; layer.open({ title : !1, type : 1, area : [ t.options.width, t.options.height ], shadeClose : !0, maxmin : !1, move : !1, scrollbar : !1, content : h }) } else { t.log() } } }) }, log : function() { console.log("请给定提示标题|文字|图片---来自[script.js]函数[helpTips]") }};

附上源码下载:

转载于:https://www.cnblogs.com/dcncy/p/10306004.html

你可能感兴趣的文章
CSS 详细解读定位属性 position 以及参数
查看>>
ed 命令 cat 命令
查看>>
想想你,幸福和快乐就来了
查看>>
html base标签 target=_parent使用介绍
查看>>
nginx实现反向代理,以反向代理tomcat为例
查看>>
团队项目冲刺5
查看>>
poj3254 Corn Fields(状压dp)
查看>>
方便记忆的电话号码
查看>>
+CIMG+彩色图片边缘提取实验记录_canny/hough transfrom
查看>>
BZOJ2179:FFT快速傅立叶(FFT)
查看>>
mysql常用命令总结
查看>>
C# Azure-让http自动跳转到https链接
查看>>
寻找符合条件的整数
查看>>
一:依使初衷
查看>>
Linux设备驱动之USB
查看>>
Active Desktop--桌面字体背景被修改
查看>>
网页中自动获取访问用户所在城市的接口插件
查看>>
锋利jquery第三章案例 总结
查看>>
Cocos Creator Animation 组件
查看>>
RH033读书笔记(1)-Lab2 Linux Usage Basics
查看>>