隐藏div悬停并显示另一个淡入淡出效果(Hide div hovering and show another down with fade effect)

编程入门 行业动态 更新时间:2024-10-26 00:32:19
隐藏div悬停并显示另一个淡入淡出效果(Hide div hovering and show another down with fade effect)

我碰巧有一个div,我想悬停在上面会产生悬停效果,并会显示另一个div相同的大小和特征,但与其他内容。 我试过用jquery不起作用,不知道我是不是会做错什么,这里我留下代码:

jQuery的:

$(function() { $('.ep1-d').hover(function() { $('.div-titulos-ep-singles-d').fadeIn(); }, function() { $('.div-titulos-ep-singles-d').fadeOut(); }); });

HTML:

<div class="ep1-d"> prueba-cambia </div> <div class="div-titulos-ep-singles-d"> <span class="titulos-ep-y-singles-texto-d"> prueba<br> <br> prueba<br> prueba<br> 9<br> </span> </div>

CSS:

.div-titulos-ep-singles-d { height: 260px; width: 260px; position:absolute; left: 465px; top: 46px; } .ep1-d { height: 260px; width: 260px; position:absolute; left: 465px; top: 46px; border: 1px solid rgba(0, 0, 0, 0.24)!important;

I happen to have a div and I would like hovering above would make a hover effect and would show another div the same size and characteristics but with other content. I've tried with jquery does not work, do not know if I'll be doing something wrong, here I leave the code:

jquery:

$(function() { $('.ep1-d').hover(function() { $('.div-titulos-ep-singles-d').fadeIn(); }, function() { $('.div-titulos-ep-singles-d').fadeOut(); }); });

html:

<div class="ep1-d"> prueba-cambia </div> <div class="div-titulos-ep-singles-d"> <span class="titulos-ep-y-singles-texto-d"> prueba<br> <br> prueba<br> prueba<br> 9<br> </span> </div>

css:

.div-titulos-ep-singles-d { height: 260px; width: 260px; position:absolute; left: 465px; top: 46px; } .ep1-d { height: 260px; width: 260px; position:absolute; left: 465px; top: 46px; border: 1px solid rgba(0, 0, 0, 0.24)!important;

最满意答案

您的代码是正确的,以及您正在使用的jquery

$(document).ready(function() { $('.ep1-d').hover(function() { $('.div-titulos-ep-singles-d').fadeIn('slow'); }, function() { $('.div-titulos-ep-singles-d').fadeOut('slow'); }); });

例如, 访问这里

新编辑

$(document).ready(function() { var $interval = ""; $('.ep1-d').on('mouseenter', function(event) { $interval = setInterval(function(){ $('.div-titulos-ep-singles-d').fadeIn("slow").promise().done(function(){ $(this).fadeOut('slow'); }); },20) }).on('mouseleave', function(event) { clearInterval($interval); }); });

例如, 访问这里

Your code is correct and along with the jquery that you are using

$(document).ready(function() { $('.ep1-d').hover(function() { $('.div-titulos-ep-singles-d').fadeIn('slow'); }, function() { $('.div-titulos-ep-singles-d').fadeOut('slow'); }); });

for example visit here

New edit

$(document).ready(function() { var $interval = ""; $('.ep1-d').on('mouseenter', function(event) { $interval = setInterval(function(){ $('.div-titulos-ep-singles-d').fadeIn("slow").promise().done(function(){ $(this).fadeOut('slow'); }); },20) }).on('mouseleave', function(event) { clearInterval($interval); }); });

for example visit here

更多推荐

本文发布于:2023-07-22 20:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1223314.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:效果   Hide   div   hovering   effect

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!