Home > Web Front-end > JS Tutorial > Example code for text prompts

Example code for text prompts

零下一度
Release: 2017-07-17 13:34:21
Original
1142 people have browsed it

The annotation part can also be implemented. The title is displayed at a fixed position when the mouse is moved over the text, and the default title is not displayed;

html web pages are mainly used for the production of web sites. The user experience of a web page is the most important. How to What about improving user experience? Let’s start with the details. So how to add hints to text links in html?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>body {
            margin: 0;
            padding: 40px;
            background: #fff;
            font: 80% Arial, Helvetica, sans-serif;
            color: #555;
            line-height: 180%;
        }

        p {
            clear: both;
            margin: 0;
            padding: .5em 0;
        }/* tooltip */#tooltip {
            position: absolute;
            border: 1px solid #333;
            background: #f7f5d1;
            padding: 1px;
            color: #333;
            display: none;
        }</style>
    <script src="js/jquery-1.11.3.min.js"></script>
    <script>$(function () {//            var v;var x=10;var y=20;
            $("a.tooltip").mouseover(function (e) {//                v=$(this).attr("title");//把class .tooltip中的值取到//                $(this).attr("title","");//把原来的titile清空this.myTitle=this.title;this.title="";var tooltip=$("<div id=&#39;tooltip&#39;>"+this.myTitle+"</div>");//把class .tooltip中的值传给新元素#tooltiptooltip.appendTo("body");var json={ "top":e.pageY+y+"px", "left":e.pageX+x+"px"};
                $("#tooltip").css(json).show("fast");
            }).mouseout(function () {
                $("#tooltip").remove();//把元素删除,不能用hide();//                $(this).attr("title",v);//把原来的属性值添加回来this.title=this.myTitle;
            });
        })</script>
</head>
</head>
<body>
<p><a href="#" class="tooltip" title="这是我的超链接提示1.">提示1.</a></p>
<p><a href="#" class="tooltip" title="这是我的超链接提示2.">提示2.</a></p>
<p><a href="#" title="这是自带提示1.">自带提示1.</a></p>
<p><a href="#" title="这是自带提示2.">自带提示2.</a></p>
</body>
</html>
Copy after login

The above is the detailed content of Example code for text prompts. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template