鼠标经过弹出提示层信息的简单实例


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>Jquery中国地图热点效果-鼠标经过弹出提示层信息的简单实例</title>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <script src="https://www.jb51.net/JS/jquery-1.8.0.min.js" type="text/javascript"></script>
    <style type="text/css">
        .map img
        {
            width: 496px;
            height: 415px;
        }
        .mapDiv
        {
            width: 140px;
            height: 61px;
            padding: 5px;
            color: #369;
            background: url('Images/dialge.gif') no-repeat;
            position: absolute;
            display: none;
            word-break: break-all;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            $("area").each(function () {
                var $x = -55;
                var $y = -80;
                var name = $(this).attr("alt");
                $(this).mouseover(function (e) {
                    var strall = [];
                    strall = $(this).attr("coords").split(",");
                    var x = parseInt(strall[0]);
                    var y = parseInt(strall[3]);
                    var index_num = $(this).index();
                    var dom = "<div><p>提示消息<span></span><span></span></p></div>";
                    $("body").append(dom);
                    $(".name").text(name);
                    $(".num").text(index_num)
                    $(".mapDiv").css({
                        left: (x + $x) + "px",
                        top: (y + $y) + "px"

}).show();
                }).mouseout(function () {
                    $(".mapDiv").remove();
                }).mousemove(function (e) {
                    $(".mapDiv").css({
                        left: (x + $x) + "px",
                        top: (y + $y) + "px"
                    })
                });
            });
            //first load
            show();
            //random
            setInterval(show, 3000); // 注意函数名没有引号和括弧
        });

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdyxjf.html