這篇文章給大家分享的是有關(guān)點(diǎn)擊HTML頁面問號出現(xiàn)提示框的實(shí)現(xiàn)方法的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考。一起跟隨小編過來看看吧。

本demo的功能:點(diǎn)擊頁面按鈕在其邊緣出現(xiàn)提示信息,點(diǎn)擊頁面任何一處則消失。
如下圖:
jquery插件;
layer插件;
==注意==:
class="j-help-tips"這個(gè)class是核心,不可缺少。
data-tips屬性是必須的。
data-tips屬性中:type:"1"不用修改;
data-tips屬性中:txt內(nèi)容即是要提示的內(nèi)容。
<html>
<head>
<link rel="stylesheet" href="style.css"" type="text/css" />
</head>
<body>
<div style="margin-top: 10%; margin-left: 10%;">
<span class="testSpan">
<i class="edi-icon j-help-tips" data-tips='{"type":"1","txt":"提示內(nèi)容111..."}'>①</i>
</span>
<span style="margin: 30px;">
<i class="edi-icon j-help-tips" data-tips='{"type":"1","txt":"提示內(nèi)容222..."}'>②</i>
</span>
<span style="margin: 30px;">
<i class="edi-icon j-help-tips" data-tips='{"type":"1","txt":"提示內(nèi)容333..."}'>③</i>
</span>
</div>
</body>
<!-- jquery -->
<script src="http://code.jquery.com/jquery-latest.js"></script>
<!-- layer -->
<script src="layer/layer.js" type="text/javascript"></script>
<!-- 提示插件 -->
<script src="script.js" type="text/javascript"></script>
<script>
$(function(){ <!-- 頁面初始化加載 -->
var tips = new helpTips().init();
}) </script></html>3.css內(nèi)容:(非必要)本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內(nèi)容:(核心)//定義提示彈出框;
var helpTipsLayer;
//定義彈出框的默認(rèn)設(shè)置;
function helpTips(t) {
this.options = {},
this.options.elem = ".j-help-tips", //與頁面class相對應(yīng);
this.options.type = 1,
this.options.color = "#8db3d7",
this.options.time = 0, //設(shè)置0是提示彈出框不會自動(dòng)消失;可設(shè)置為其他數(shù)字,以毫秒為單位;
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() {
//點(diǎn)擊頁面任何一處可使提示彈出框消失;
$(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);//點(diǎn)擊其他任意的提示框按鈕,則關(guān)閉上一個(gè)提示框。
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="m-popup-ct">',
n = '<h4 class="tt"><span class="txt_01">' + o.title + t.options.titleEnd + '</span></h4><p class="line_01"></p>',
s = "</p>",
l = '<ul class="u-explain-list">',
p = o.txt.split("|"),
a = p.length;
a > 0 && $.each(p, function(t, i) {
l += '<li><i class="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="f-mr5">' + (a + 1) + "</i><img src=" + o.img + ' width="' + c + '" height="' + 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("請給定提示標(biāo)題|文字|圖片---來自[script.js]函數(shù)[helpTips]")
}
};感謝各位的閱讀!關(guān)于點(diǎn)擊HTML頁面問號出現(xiàn)提示框的實(shí)現(xiàn)方法就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
文章題目:點(diǎn)擊HTML頁面問號出現(xiàn)提示框的實(shí)現(xiàn)方法-創(chuàng)新互聯(lián)
瀏覽路徑:http://www.chinadenli.net/article32/dehisc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、網(wǎng)站內(nèi)鏈、網(wǎng)站設(shè)計(jì)公司、營銷型網(wǎng)站建設(shè)、ChatGPT、企業(yè)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容