Jquery creates a layer that does not disappear when the mouse moves over the layer

  • 2020-03-30 00:53:12
  • OfStack

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title> Headless document </title> 
<style type="text/css"> 
#Adiv div {float:left; width:100px;border:1px solid #333;margin-top:100px;} 
#SDiv {width:135px;position: absolute;} 
<script type="text/javascript" src="js/jquery-1.7.2.js"></script> 
<script type="text/javascript"> 
var x = -90; 
var y = -70; 
$("#Adiv div").mouseenter(function(e){ 
this.xx = ($(this).index() + 1) * 100; 
this.yy = $(this).offset().top; 
var login = $(this).attr("href"); 
var div = "<div id='SDiv' style='border:1px solid #333'><img src='images/login_box/box_onmouse.png' border='0' usemap='#Map' /><map name='Map' id='Map'><area shape='rect' id='divLogin' coords='16,14,67,35' href="+login+" /><area shape='rect' id='divRegister' coords='75,15,127,37' href='http://www.baidu.com' /></map></div>"; 
$("#SDiv").css({ "top": (this.yy + y) + "px", "left": (this.xx + x) + "px" }); 
}).mouseleave(function (e) { 
var ex = e.pageX; 
var ey = e.pageY; 
var sx = $("#SDiv").offset().top; 
var sxx = $("#SDiv").offset().top + 72; 
var sy = $("#SDiv").offset().left; 
var syy = $("#SDiv").offset().left + 135; 
if(ey > sx && ey <= sxx && ex > sy && ex <= syy){ 
return false; 

<div class="box_onmouse"><img src="images/login_box/box_onmouse.png" border="0" usemap="#Map" /> 
<map name="Map" id="Map"> 
<area shape="rect" id="divLogin" coords="16,14,67,35" href="#" /> 
<area shape="rect" id="divRegister" coords="75,15,127,37" href="#" /> 
<div id="Adiv"> 
<div href="11111">1111111</div> 
<div href="22222">2222222</div> 
<div href="33333">3333333</div> 
<div> There is a requirement in the project to move the mouse over something div At the top, dynamically create a layer that contains 2 Each image is linked to a different address div Provided), mouse to remove this layer to remove the created div If the mouse moves over to this created div The top is not removed </div> 

Related articles: