Jquery USES mouseenter and mouseleave to implement a mouse over pop up layer that can be clicked

  • 2020-03-30 01:44:11
  • OfStack

The example is as follows:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Jquery using mouseenter and mouseleave Mouse over the pop-up layer and can be clicked </title>
    <script src="JS/jquery-1.9.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var ps = $("#div_pro").position();
            $("#float_box").css("position", "absolute");
            $("#float_box").css("left", ps.left + 20); //Distance left
            $("#float_box").css("top", ps.top + 20); //Top distance
            $("#div_pro").mouseenter(function () {
                $("#float_box").show();
            });
            $("#float_box").mouseleave(function () {
                $("#float_box").hide();
            });
        })
    </script>
</head>
<body>
    <div>
        <a href="#" id="div_pro"> Guangdong province, </a>
    </div>
    <div id="float_box" style="display:none;">
        <a href="#"> shenzhen </a>    
        <a href="#"> guangzhou </a>
        <a href="#"> Dongguan city, </a>
    </div>
</body>
</html>

Related articles: