Home > Web Front-end > JS Tutorial > body text

How to give a picture prompt in js?

零下一度
Release: 2017-07-17 14:29:59
Original
1060 people have browsed it

How to give a picture prompt in js? Let me share one with you below.

//Sharp jQuery example

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

        img {
            border: none;
        }

        ul, li {
            margin: 0;
            padding: 0;
        }

        li {
            list-style: none;float: left;
            display: inline;
            margin-right: 10px;
            border: 1px solid #AAAAAA;
        }/* tooltip */#tooltip {
            position: absolute;
            border: 1px solid #ccc;
            background: #333;
            padding: 2px;
            display: none;
            color: #fff;
        }</style>
    <script src="js/jquery-1.11.3.min.js"></script>
    <script>var x=10;var y=20;
        $(function () {
          $(".tooltip").mouseover(function (e) {              this.title="";              var href=$(this).attr("href")              var tooltip=$('<div id="tooltip"><img src="&#39;+href+&#39;"/></div>')
              tooltip.appendTo("body");              var json={ "top":e.pageY+y+"px", "left":e.pageX+x+"px"};
              $("#tooltip").css(json).show("fast");
          }).mouseout(function () {
              $("#tooltip").remove();
          })
        })</script>
</head>
<body>
<h3>有效果:</h3>
<ul>
    <li><a href="images/apple_1_bigger.jpg" class="tooltip" title="苹果 iPod"><img src="images/apple_1.jpg" alt="苹果 iPod"/></a></li>
    <li><a href="images/apple_2_bigger.jpg" class="tooltip" title="苹果 iPod nano"><img src="images/apple_2.jpg"  alt="苹果 iPod nano"/></a></li>
    <li><a href="images/apple_3_bigger.jpg" class="tooltip" title="苹果 iPhone"><img src="images/apple_3.jpg"   alt="苹果 iPhone"/></a></li>
    <li><a href="images/apple_4_bigger.jpg" class="tooltip" title="苹果 Mac"><img src="images/apple_4.jpg" alt="苹果 Mac"/></a>
    </li>
</ul>


<br/><br/><br/><br/>
<br/><br/><br/><br/>


<h3>无效果:</h3>
<ul>
    <li><a href="images/apple_1_bigger.jpg" title="苹果 iPod"><img src="images/apple_1.jpg" alt="苹果 iPod"/></a></li>
    <li><a href="images/apple_2_bigger.jpg" title="苹果 iPod nano"><img src="images/apple_2.jpg" alt="苹果 iPod nano"/></a>
    </li>
    <li><a href="images/apple_3_bigger.jpg" title="苹果 iPhone"><img src="images/apple_3.jpg" alt="苹果 iPhone"/></a></li>
    <li><a href="images/apple_4_bigger.jpg" title="苹果 Mac"><img src="images/apple_4.jpg" alt="苹果 Mac"/></a></li>
</ul>
</body>
</html>
Copy after login

The above is the detailed content of How to give a picture prompt in js?. 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