这篇文章给大家分享的是有关点击HTML页面问号出现提示框的实现方法的内容。小编觉得挺实用的,因此分享给大家做个参考。一起跟随小编过来看看吧。
创新互联建站专业为企业提供祥符网站建设、祥符做网站、祥符网站设计、祥符网站制作等企业网站建设、网页设计与制作、祥符企业网站模板建站服务,十余年祥符做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
本demo的功能:点击页面按钮在其边缘出现提示信息,点击页面任何一处则消失。
如下图:
jquery插件;
layer插件;
==注意==:
class="j-help-tips"这个class是核心,不可缺少。
data-tips属性是必须的。
data-tips属性中:type:"1"不用修改;
data-tips属性中:txt内容即是要提示的内容。
①
②
③
本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;
}//定义提示弹出框;
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 = '感谢各位的阅读!关于点击HTML页面问号出现提示框的实现方法就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到吧!