Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使文本淡入并保持可见,直到鼠标离开容器_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 使文本淡入并保持可见,直到鼠标离开容器

Javascript 使文本淡入并保持可见,直到鼠标离开容器,javascript,jquery,html,css,Javascript,Jquery,Html,Css,当鼠标指针在容器中时,我要使文本fadeIn保持可见,只有当鼠标指针离开指定区域时,文本才会消失,但由于某种原因它不起作用,即使鼠标在容器内,文本也会逐渐消失 我正在使用jQueryLib1.10.1以及jQueryUI1.11.0 代码如下: HTML <script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script> <div class="hold"> <div class="c

当鼠标指针在容器中时,我要使文本
fadeIn
保持可见,只有当鼠标指针离开指定区域时,文本才会消失,但由于某种原因它不起作用,即使鼠标在容器内,文本也会逐渐消失

我正在使用jQueryLib1.10.1以及jQueryUI1.11.0

代码如下:

HTML

<script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<div class="hold">
    <div class="conti">
        <div class="arrow-right"></div>
    </div>
    <div class="text-fade"></div>  
</div>
JS

.hold{
    width: 142px;
    background: yellow;
    overflow: hidden;
    padding:10px;
}
.conti{
    width: 30px;
}
.arrow-right {
    width: 0; 
    height: 0; 
    border-top: 20px solid transparent;
    border-bottom: 20px solid transparent;
    border-left: 20px solid green;
}
.text-fade{
    display: none;
    float: right;
    margin-top:-30px;
    margin-left: 10px;
    margin-right:10px;
}
$('.hold').mouseenter(function () {
    $('.arrow-right').effect("bounce", { direction:'right', times:3 }, 700);
    $('.text-fade').text("this is a test text").fadeIn(1000).css('display',"block");
});
$('.hold').mouseout(function () {
    $('.text-fade').fadeOut(1000);
});

这是指向我的

的链接,将文本直接放入“.text fade”,并对“.text fader”类进行一些转换。然后通过JS更改文本颜色

以下是从#FFFFFF更改为#000000并再次更改的代码:

$('.hold').mouseenter(function () {
    $('.arrow-right').effect("bounce", { direction:'right', times:3 }, 700);
    $('.text-fade').css('color', '#000000');
});
$('.hold').mouseout(function () {
    $('.text-fade').css('color', '#FFFFFF');
});

将文本直接放入“.text fader”中,并对“.text fader”类进行一些转换。然后通过JS更改文本颜色

以下是从#FFFFFF更改为#000000并再次更改的代码:

$('.hold').mouseenter(function () {
    $('.arrow-right').effect("bounce", { direction:'right', times:3 }, 700);
    $('.text-fade').css('color', '#000000');
});
$('.hold').mouseout(function () {
    $('.text-fade').css('color', '#FFFFFF');
});

将文本直接放入“.text fader”中,并对“.text fader”类进行一些转换。然后通过JS更改文本颜色

以下是从#FFFFFF更改为#000000并再次更改的代码:

$('.hold').mouseenter(function () {
    $('.arrow-right').effect("bounce", { direction:'right', times:3 }, 700);
    $('.text-fade').css('color', '#000000');
});
$('.hold').mouseout(function () {
    $('.text-fade').css('color', '#FFFFFF');
});

将文本直接放入“.text fader”中,并对“.text fader”类进行一些转换。然后通过JS更改文本颜色

以下是从#FFFFFF更改为#000000并再次更改的代码:

$('.hold').mouseenter(function () {
    $('.arrow-right').effect("bounce", { direction:'right', times:3 }, 700);
    $('.text-fade').css('color', '#000000');
});
$('.hold').mouseout(function () {
    $('.text-fade').css('color', '#FFFFFF');
});

mouseout由儿童触发,请改用mouseleave

$('.hold').mouseenter(function () {
    // var d = $('.arrow-right');
    // d.effect("bounce", { direction:'right', times:3 }, 700);
    $('.text-fade').text("this is a test text").fadeIn(1000);
});
$('.hold').mouseleave(function () {
    $('.text-fade').fadeOut(1000);
});

mouseeut由儿童触发,请改用mouseleave

$('.hold').mouseenter(function () {
    // var d = $('.arrow-right');
    // d.effect("bounce", { direction:'right', times:3 }, 700);
    $('.text-fade').text("this is a test text").fadeIn(1000);
});
$('.hold').mouseleave(function () {
    $('.text-fade').fadeOut(1000);
});

mouseeut由儿童触发,请改用mouseleave

$('.hold').mouseenter(function () {
    // var d = $('.arrow-right');
    // d.effect("bounce", { direction:'right', times:3 }, 700);
    $('.text-fade').text("this is a test text").fadeIn(1000);
});
$('.hold').mouseleave(function () {
    $('.text-fade').fadeOut(1000);
});

mouseeut由儿童触发,请改用mouseleave

$('.hold').mouseenter(function () {
    // var d = $('.arrow-right');
    // d.effect("bounce", { direction:'right', times:3 }, 700);
    $('.text-fade').text("this is a test text").fadeIn(1000);
});
$('.hold').mouseleave(function () {
    $('.text-fade').fadeOut(1000);
});

您使用了错误的函数,它的mouseenter()和mouseleave()

你的javascript

$('.hold').mouseenter(function () {
    $('.text-fade').text("this is a test text");
    $('.text-fade').fadeIn(1000);
    $('.text-fade').show();
});
$('.hold').mouseleave(function () {
    $('.text-fade').fadeOut(1000);
});

另外,您使用的bounce函数似乎会导致一些问题,我无法找到原因,所以我将其删除了

您使用了错误的函数,它的mouseenter()和mouseleave()

你的javascript

$('.hold').mouseenter(function () {
    $('.text-fade').text("this is a test text");
    $('.text-fade').fadeIn(1000);
    $('.text-fade').show();
});
$('.hold').mouseleave(function () {
    $('.text-fade').fadeOut(1000);
});

另外,您使用的bounce函数似乎会导致一些问题,我无法找到原因,所以我将其删除了

您使用了错误的函数,它的mouseenter()和mouseleave()

你的javascript

$('.hold').mouseenter(function () {
    $('.text-fade').text("this is a test text");
    $('.text-fade').fadeIn(1000);
    $('.text-fade').show();
});
$('.hold').mouseleave(function () {
    $('.text-fade').fadeOut(1000);
});

另外,您使用的bounce函数似乎会导致一些问题,我无法找到原因,所以我将其删除了

您使用了错误的函数,它的mouseenter()和mouseleave()

你的javascript

$('.hold').mouseenter(function () {
    $('.text-fade').text("this is a test text");
    $('.text-fade').fadeIn(1000);
    $('.text-fade').show();
});
$('.hold').mouseleave(function () {
    $('.text-fade').fadeOut(1000);
});


另外,您的弹跳功能似乎导致了一些问题,我无法找出原因,因此我将其删除

看起来您的小提琴指向了另一个问题<代码>$(this).effect(“反弹”{direction:'right',times:1},700)看起来你的小提琴与上面的代码不一致?你当前的代码是什么?看,当鼠标悬停在文本上时,它会消失。我有点修复了容器问题,但我只希望当鼠标离开实际容器时,文本会消失。为什么不使用纯CSS3呢?@VinceCgto为什么我不使用纯CSS,因为浏览器兼容性问题,jquery倾向于消除这个问题完全,而且在与客户打交道时,这始终是一个更安全的选择,这是一个非常老派的、陷于石器时代的客户,看起来你的小提琴指向了一个不同的问题<代码>$(this).effect(“反弹”{direction:'right',times:1},700)看起来你的小提琴与上面的代码不一致?你当前的代码是什么?看,当鼠标悬停在文本上时,它会消失。我有点修复了容器问题,但我只希望当鼠标离开实际容器时,文本会消失。为什么不使用纯CSS3呢?@VinceCgto为什么我不使用纯CSS,因为浏览器兼容性问题,jquery倾向于消除这个问题完全,而且在与客户打交道时,这始终是一个更安全的选择,这是一个非常老派的、陷于石器时代的客户,看起来你的小提琴指向了一个不同的问题<代码>$(this).effect(“反弹”{direction:'right',times:1},700)看起来你的小提琴与上面的代码不一致?你当前的代码是什么?看,当鼠标悬停在文本上时,它会消失。我有点修复了容器问题,但我只希望当鼠标离开实际容器时,文本会消失。为什么不使用纯CSS3呢?@VinceCgto为什么我不使用纯CSS,因为浏览器兼容性问题,jquery倾向于消除这个问题完全,而且在与客户打交道时,这始终是一个更安全的选择,这是一个非常老派的、陷于石器时代的客户,看起来你的小提琴指向了一个不同的问题<代码>$(this).effect(“反弹”{direction:'right',times:1},700)看起来你的小提琴与上面的代码不一致?你当前的代码是什么?看,当鼠标悬停在文本上时,它会消失。我有点修复了容器问题,但我只希望当鼠标离开实际容器时,文本会消失。为什么不使用纯CSS3呢?@VinceCgto为什么我不使用纯CSS,因为浏览器兼容性问题,jquery倾向于消除这个问题完全和它始终是一个更安全的选择,当与客户打交道时,这是一个超级老派和陷入石器时代,文本的颜色不能改变,因为它将被放在一个滑块上作为一个行动的调用看到,所以我只需要文本淡出一旦鼠标离开滑块所在的容器,很抱歉,兄弟,你的答案不起作用,但是为答案拍照兄弟,文本的颜色不能改变,因为它将作为滑块上的动作调用,请看,因此我只需要在鼠标离开滑块所在的容器后,文本才会淡出,很抱歉,兄弟,你的答案不起作用,但是为答案拍照兄弟,文本的颜色不能改变,因为它将被放在一个滑块上作为一个行动的号召,看,所以我只需要文本淡出