2
I was programming a simple profile and I want to put a delay after the 'mouseenter' as soon as the mouse enters this 'mouseenter' and along with delay to show a box called '.user_widget' I am using:
addClass and removeClass;
Css:
.user_widget {
background-color: rgb(255, 255, 255);
position: relative;
top: 39px;
width: 210px;
height: 305px;
z-index: 4;
border-radius: 3px;
margin: 0 auto;
box-shadow: 0 10px 20px 0px rgba(0, 0, 0, 0.14);
}
.ativo {
display: block !important;
background-color: rgb(255, 255, 255)!important;
}
.desativado {
display: none !important;
}
HTML and Javascript:
<div class="user_widget desativado">
<script type="text/javascript">
$(".user").click(function(){
$('.user_widget').addClass('desativado');
$('.user_widget').removeClass('ativo');
$('.user').removeClass('ativo');
});
</script>
<script type="text/javascript">
$(".user").mouseenter(function(){
$('.user_widget').removeClass('desativado');
$('.user').addClass('ativo');
$('.user_widget').addClass('ativo');
});
</script>
Hello Rafa, only type guy, I’m using background to change the color of the user behind when entering the mouseenter, only it’s very fast; Look at a print: http://prntscr.com/fnd18r I’m new to javascript yet :/
– user81560
Okay, I’ve changed, take a look at this way, very simple and do what you want
– Rafa Zanezi
Then Rafa I put like this: <div class="user" onmouseenter="setTimeout(mouseEnter,delay);"> Only that nothing happened when I pass the mouse.
– user81560
replace with onmouseover="javascript:setTimeout(mouseEnter,delay);"
– Rafa Zanezi
Nothing happens, http://prntscr.com/fnd87s error in javascript : http://prntscr.com/fnd8jr
– user81560
prints the "user class"
– Rafa Zanezi
http://prntscr.com/fnda1m
– user81560
what are the attributes of your user class? you have a css for it?
– Rafa Zanezi
.user { border-Radius: 50%; background-color: rgba(255, 255, 255, 0.76); opacity: 1; position: relative; z-index: 7; top: 14px; width: 24px; height: 29px; margin: 0 auto; padding-left: 13px; padding-top: 8px; left: 1px; }
– user81560
Rafa discovered, you forgot to close mano kk, $('.user_widget'). addClass('active'); }; </script>
– user81560
ok I will edit the answer, if it worked, indicate the answer as solution
– Rafa Zanezi
Only there’s one more brother, you see I used the click too? As soon as I give this Hover, I want it to stay active, and then I click and it closes, you can help me with that?
– user81560
this is because its class "disabled" is receiving a "display:None;" so it will make the element disappear
– Rafa Zanezi
But using javascript, I give one. click on it and add class "active" with "display: block", I put so, only when I take the mouse the onmouseover continues with the effect of it.
– user81560
these two methods work differently, read the jquery documentation first, then try redoing your question https://api.jquery.com/mouseover/ https://api.jquery.com/click/
– Rafa Zanezi
I’ll take a look Rafa, thanks, what I want is a delay as soon as I pass the mouse over the "user", a delay of 1s, only I want to leave the "user_widget" active without closing, and then when I click on the "user" again it closes with "display: None" which would be the class "disabled".
– user81560