jquery creates a layer when the mouse moves onto the layer without disappearing the effect

Source: Internet
Author: User

  Use jquery to create a layer that does not disappear when the mouse is moved above the layer, sample code is as follows, and interested friends can refer to the following

The code is as follows: <! 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 ">  <head>  <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/>  <title> Untitled document </title>  <style type=" text/css ">  #Adiv div { Float:left; width:100px;border:1px solid #333; margin-top:100px;}   #SDiv {width:135px;position:absolute;}   </style>  <script type= "Text/javascript" src= "Js/jquery-1.7.2.js" ></script>  <script type= "Text/javascript" >  $ (function () {  var x = -90;  var y = -70;  $ ("#Adiv div"). Mouse Enter (function (e) {  this.xx = ($ (this). Index () + 1) * 100;  this.yy = $ (this). Offset () .top;  var login = $ ( This). attr ("href");  if ($ ("#SDiv")) {$ ("#SDiv"). Remove ();   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 ' ' http://www.baidu.com '/></map></div> ';  $ ("Body"). Append (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 = $ ("#SD IV "). Offset () .left;  var syy = $ (" #SDiv "). Offset (). Left + 135;  if (ey > SX && ey <= sxx && ex > Sy && ex <= Syy) {  $ ("#SDiv"). MouseLeave (function () {$ ("#SDiv"). Remove ();});   Return false; }  $ ("#SDiv"). Remove (); }); })   </script>  </head>& nbsp     <body>  <!--  <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= "#"/>  </map>  </div> -->  < Div id= "Adiv" >  <div href= "11111" >1111111</div>  <div href= "22222" >2222222</div >  <div href= "33333" >3333333</div>  </div>  <div> There are requirements in the project: the mouse moved to a div above the dynamic creation of a layer, this layer has 2 button pictures (art switch), each picture link different address (the link address has the previous Div provided), the mouse removed this layer will remove the created Div, If you move the mouse over this created Div, do not remove </div>  </body>  </html>   
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.