html - How do I cancel a JQuery animation on a div, when another div lays over it -


i try make kind of menu on side of website small part of menu showing , when hover on it, slides out can click on it. rest of menu beneath main website div , problem when hover on div beneath main website, still activate animation should not happen.

<body>     <div id="container">         <div id="header">             <img id="headerimg" src="pokebalicon.png" />        </div>        <div class="sidediv" id="first" style="margin-top: 100px;">            <p></p>        </div>        <div id="mainpage">            text        </div>     </div> </body> 

the css

#container {     width: 820px;     height: 700px;     margin: 100px auto;     position: relative; } #header {     padding: 10px;     height: 100px;     width: 100%;     background-color: transparent;     overflow: hidden; } #mainpage {     height: 600px;     width: 100%;     background-color: #ffffff;     border-radius: 10px;     padding: 20px;     border: 1px solid #d5d4d4;     position: absolute;     pointer-events: none; } .sidediv{     position: absolute;     left: 721px;     top: 80px;     height: 40px;     width: 170px;     text-align: center;     margin-top: 50px;     border-radius: 0 5px 5px 0;     background-image: url(wood.png);     background-size: cover; } 

and jquery

$(document).ready(function(){     $('#first').mouseenter(function() {         $('#first').animate({             left:'841px'         });     });     $('#first').mouseleave(function() {         $('#first').animate({             left:'721px'         });     }); }); 

anybody has idea how solve problem? clarify, here images

view of menuhttp://imgur.com/q8dq7n7 happens when hover on menu view of menu while hovering on ithttp://imgur.com/fvdca4e menu lays beneath white div when hovering on white div , menu, starts animation , tries slide out not supposed happen.

you have change structure of sidediv. basically, you're gonna have have element mouse over, lets call .arrowside , 1 content on we're making sidediv parent.

<div id="container">     <div id="header">         <img id="headerimg" src="https://g.twimg.com/about/feature-corporate/image/typography.png" />    </div>      <div id="mainpage">        text    </div>     <div class="sidediv" style="margin-top: 100px;">        <span class="consentside"> asdas </span>        <span class="arrowside">  > > > </span>    </div>     <div class="sidediv" style="margin-top: 150px;">        <span class="consentside"> 4234234 </span>        <span class="arrowside">  > > > </span>    </div>  </div>  

also added little bit of css

.arrowside{    float : right; } 

and jquery, did self = parent element not lost. here's how works; want each, let's say, menu item, have 3 elements, 1 tip of menu , other content , have parent div. basically, mouse enters little bit of menu thats out, menu move out , menu go in need move mouse out of parent div.

$('.sidediv').each(function(){     var self = this;      $(self).find('.arrowside').mouseenter(function(){     $(self).stop().animate({width: '390px'}, 1000); });     $(self).mouseleave(function(){         $(self).stop().animate({width: '170'}, 1000)     });  }); 

here's jsfiddle .


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -