Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 624 Vote(s) - 3.47 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Javascript: Div slide down on another div

#1
In this jsfiddle, I would like the "#video" div to slide down completely and stay until the mouse is over "#wrap". But its going up and down even though the mouse is on #wrap. Any idea?

html:

<div id="wrap">
<div id="text">text</div>
<div id="video">video</div>
</div>

css:

#text
{
position: absolute;
top:20px;
width: 300px;
height: 200px;
background: #FAAC58;
margin-left:auto;
margin-right:auto;
}

#video
{
position: absolute;
top:20px;
width: 300px;
height: 200px;
display:none;
background: rgba(0,0,0,0.8);
}

Jscript:

$(document).ready(function(){
$("#wrap").mouseover(function(){
$("#video").slideDown("slow");
});
$("#wrap").mouseout(function(){
$("#video").slideUp("slow");
});
});

[To see links please register here]

Reply

#2
use mouseenter and mouseleave instead. It will handle the mouseover bubbling (

[To see links please register here]

)
Reply

#3
The `mouseover()` and `mouseout()` functions are called continuously when the mouse is moving. Try instead using [`mouseenter()`][1] and [`mouseout()`][2] so that the event is only fired once:

$("#wrap").mouseenter(function() {
$("#video").slideDown("slow");
});
$("#wrap").mouseleave(function() {
$("#video").slideUp("slow");
});


Here's a link to [an updated JSFiddle][3].


[1]:

[To see links please register here]

[2]:

[To see links please register here]

[3]:

[To see links please register here]

Reply

#4
when `#video` slides down, it comes on `#wrap` so mouse pointer becomes on `#video` then `$("#wrap").mouseout` is triggered

Try this:

$(document).ready(function(){
$("#wrap").mouseover(function(){
$("#video").slideDown("slow");
});
$("#video").mouseout(function(){
$("#video").slideUp("slow");
});
});
Reply

#5
Use the `hover` event instead of `mouseover` and `mouseout`, your `mouseover` get triggered many times as the mouse moves inside the div `#wrap`

$(document).ready(function () {
$("#wrap").hover(function () {
$("#video").slideDown("slow");
}, function () {
$("#video").slideUp("slow");
});
});

[fiddle][1]


[1]:

[To see links please register here]

Reply

#6
When your #video div covers up the #wrap div, it triggers the mouseout event. One option is to use a third see-through div above both #video and #wrap and use that to trigger the events:

<div id="wrap">
<div id="text">text</div>
<div id="video">video</div>
<div id="cursor"></div>
</div>

$(document).ready(function(){
$("#cursor").mouseover(function(){
$("#video").slideDown("slow");
});
$("#cursor").mouseout(function(){
$("#video").slideUp("slow");
});
});

Here's the updated working code:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through