search
HomeWeb Front-endHTML TutorialClick the question mark on the HTML page and a prompt box will appear (source code attached)

The content of this article is about clicking the question mark on the HTML page to display a prompt box (source code attached). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. helped.

The function of this demo: click on the page button and a prompt message will appear on its edge, and click anywhere on the page to disappear.

As shown below:
Click the question mark on the HTML page and a prompt box will appear (source code attached)

1. Required plug-ins:

  • ##jquery plug-in;

  • layer plug-in;

2.HTML content:

==Note==:

  1. class="j-help-tips"This class is the core and indispensable.

  2. data-tips attribute is required.

  3. In the data-tips attribute: type: "1" does not need to be modified;

  4. In the data-tips attribute: the txt content is the prompt Content.

  5. <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=&#39;{"type":"1","txt":"提示内容111..."}&#39;>①</i>
                </span>
                
                <span style="margin: 30px;">
                    <i class="edi-icon j-help-tips" data-tips=&#39;{"type":"1","txt":"提示内容222..."}&#39;>②</i>
                </span>
                
                <span style="margin: 30px;">
                    <i class="edi-icon j-help-tips" data-tips=&#39;{"type":"1","txt":"提示内容333..."}&#39;>③</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 content: (not necessary)

  • The css of this demo is not necessary and does not affect the function;

  • .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 content: (core)

//定义提示弹出框;
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 = &#39;<p class="m-popup-ct">&#39;,
                        n = &#39;<h3 id="span-nbsp-class-txt-nbsp-nbsp-o-title-nbsp-nbsp-t-options-titleEnd-nbsp-nbsp-span"><span class="txt_01">&#39; + o.title + t.options.titleEnd + &#39;</span></h3><p class="line_01"></p>&#39;,
                        s = "</p>",
                        l = &#39;<ul class="u-explain-list">&#39;,
                        p = o.txt.split("|"),
                        a = p.length;
                    a > 0 && $.each(p, function(t, i) {
                        l += &#39;<li><i class="f-mr5">&#39; + (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 += &#39;<li><i class="f-mr5">&#39; + (a + 1) + "</i><img  src="/static/imghwm/default1.png"  data-src=" + o.img + &#39;    style="max-width:90%"lazy"  &#39; + c + &#39;" height="&#39; + d + &#39;"/ alt="Click the question mark on the HTML page and a prompt box will appear (source code attached)" ></li>&#39;, 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]")
    }
};

The above is the detailed content of Click the question mark on the HTML page and a prompt box will appear (source code attached). For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:博客园. If there is any infringement, please contact admin@php.cn delete
What is the difference between an HTML tag and an HTML attribute?What is the difference between an HTML tag and an HTML attribute?May 14, 2025 am 12:01 AM

HTMLtagsdefinethestructureofawebpage,whileattributesaddfunctionalityanddetails.1)Tagslike,,andoutlinethecontent'splacement.2)Attributessuchassrc,class,andstyleenhancetagsbyspecifyingimagesources,styling,andmore,improvingfunctionalityandappearance.

The Future of HTML: Evolution and TrendsThe Future of HTML: Evolution and TrendsMay 13, 2025 am 12:01 AM

The future of HTML will develop in a more semantic, functional and modular direction. 1) Semanticization will make the tag describe the content more clearly, improving SEO and barrier-free access. 2) Functionalization will introduce new elements and attributes to meet user needs. 3) Modularity will support component development and improve code reusability.

Why are HTML attributes important for web development?Why are HTML attributes important for web development?May 12, 2025 am 12:01 AM

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

What is the purpose of the alt attribute? Why is it important?What is the purpose of the alt attribute? Why is it important?May 11, 2025 am 12:01 AM

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

HTML, CSS, and JavaScript: Examples and Practical ApplicationsHTML, CSS, and JavaScript: Examples and Practical ApplicationsMay 09, 2025 am 12:01 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

How do you set the lang attribute on the  tag? Why is this important?How do you set the lang attribute on the tag? Why is this important?May 08, 2025 am 12:03 AM

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

What is the purpose of HTML attributes?What is the purpose of HTML attributes?May 07, 2025 am 12:01 AM

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

How do you create a list in HTML?How do you create a list in HTML?May 06, 2025 am 12:01 AM

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool