点击HTML页面问号出现提示框(附源码)
本demo的功能:点击页面按钮在其边缘出现提示信息,点击页面任何一处则消失。
如下图:

jquery插件;
layer插件;
2.HTML内容:==注意==:
class=https://www.ym97.com/"j-help-tips"这个class是核心,不可缺少。
data-tips属性是必须的。
data-tips属性中:type:"1"不用修改;
data-tips属性中:txt内容即是要提示的内容。
<html> <head> <link rel=https://www.ym97.com/"stylesheet" href=https://www.ym97.com/"style.css"" type=https://www.ym97.com/"text/css" /> </head> <body> <div style=https://www.ym97.com/"margin-top: 10%; margin-left: 10%;"> <span class=https://www.ym97.com/"testSpan"> <i class=https://www.ym97.com/"edi-icon j-help-tips" data-tips='{"type":"1","txt":"提示内容111..."}'>①</i> </span> <span style=https://www.ym97.com/"margin: 30px;"> <i class=https://www.ym97.com/"edi-icon j-help-tips" data-tips='{"type":"1","txt":"提示内容222..."}'>②</i> </span> <span style=https://www.ym97.com/"margin: 30px;"> <i class=https://www.ym97.com/"edi-icon j-help-tips" data-tips='{"type":"1","txt":"提示内容333..."}'>③</i> </span> </div> </body> <!-- jquery --> <script src=https://www.ym97.com/"http:/code.jquery.com/jquery-latest.js"></script> <!-- layer --> <script src=https://www.ym97.com/"layer/layer.js" type=https://www.ym97.com/"text/javascript"></script> <!-- 提示插件 --> <script src=https://www.ym97.com/"script.js" type=https://www.ym97.com/"text/javascript"></script> <script> $(function(){ <!-- 页面初始化加载 --> var tips = new helpTips().init(); }) </script></html>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 = '<p class=https://www.ym97.com/"m-popup-ct">', n = '<h3 class=https://www.ym97.com/"tt"><span class=https://www.ym97.com/"txt_01">' + o.title + t.options.titleEnd + '</span></h3><p class=https://www.ym97.com/"line_01"></p>', s = "</p>", l = '<ul class=https://www.ym97.com/"u-explain-list">', p = o.txt.split("|"), a = p.length; a > 0 && $.each(p, function(t, i) { l += '<li><i class=https://www.ym97.com/"f-mr5">' + (t + 1) + "</i>" + i + "</li>" }); 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 += '<li><i class=https://www.ym97.com/"f-mr5">' + (a + 1) + "</i><img src=https://www.ym97.com/" + o.img + ' width=https://www.ym97.com/"' + c + '" height=https://www.ym97.com/"' + d + '"/></li>', l += "</ul>"; 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]") } };以上就是点击HTML页面问号出现提示框(附源码)的详细内容,更多请关注php中文网其它相关文章!
相关热词: HTML
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jiaob/cssm/7303.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
其中border-left决定了底部直
时间:2021-01-23
-
当你自己回头来看你写的
时间:2021-01-23
-
④格式标签 粗体:b/b 斜
时间:2021-01-23
-
我们直接看代码: !DOCTY
时间:2021-01-23
-
这里就是吐槽的IE6!) 图
时间:2021-01-23
-
假设我们的HTML代码如下:
时间:2021-01-23
-
那么使用 CSS3 新增的选择
时间:2021-01-23
-
scaleGlassRectangle.y
时间:2021-01-23
热门文章
-
可以加我的HTML5前端交流群111645711 CSS源码
时间:2021-01-15
-
就可以对子元素进行 3D 变形操作了
时间:2021-01-12
-
用css让一个容器水平垂直
时间:2021-01-12
-
而没有设置高度
时间:2021-01-19
-
canvas与html5实现视频截图成果
时间:2021-01-19
-
所以通常不需要发送
时间:2021-01-19
-
我们尝试一下更新一下HTML结构
时间:2021-01-23
-
scaleGlassRectangle.y
时间:2021-01-23
-
HTML5生拖放实例分析
时间:2021-01-12
-
在全局:root{ }伪类中定义了一个 CSS 变量
时间:2021-01-21
