Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.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
在悬停时,使用jQuery淡出和淡出子对象_Jquery_Html_Hover_Children - Fatal编程技术网

在悬停时,使用jQuery淡出和淡出子对象

在悬停时,使用jQuery淡出和淡出子对象,jquery,html,hover,children,Jquery,Html,Hover,Children,我试图在浏览父div.content时淡入div.description。我的页面中有几个这样的项目,所以我不知道如何在jQuery代码中实现children()。现在,当我将鼠标悬停在1.content上时,每个.description都会淡出 以下是HTML: <div class="item"> <div class="content"> <div class="description"> <p>

我试图在浏览父div.content时淡入div.description。我的页面中有几个这样的项目,所以我不知道如何在jQuery代码中实现children()。现在,当我将鼠标悬停在1.content上时,每个.description都会淡出

以下是HTML:

<div class="item">
    <div class="content">
        <div class="description">
            <p>
                <span>Super Garfield</span><br />
                <span>by myself</span>
            </p>
        </div>
        <div class="image" style="background-image: url('style/img/body-item-sample1.png')"></div>
    </div>
    <div class="view">
        1234
    </div>
    <div class="like">
        1234
    </div>
</div>


超级加菲猫
我一个人

1234 1234
以下是jQuery:

<script>
    $(document).ready(function(){
        $(".content").hover(function(){
            $(".description").fadeIn(100); // This should set the opacity to 100% on hover
        },function(){
            $(".description").fadeOut(100); // This should set the opacity back to 30% on mouseout
        });
    });
</script>

$(文档).ready(函数(){
$(“.content”).hover(函数(){
$(“.description”).fadeIn(100);//悬停时应将不透明度设置为100%
},函数(){
$(“.description”).fadeOut(100);//这将在鼠标移出时将不透明度设置回30%
});
});
您想要“>”

e、 g:

您想要“>”

e、 g:


你很接近了。使用
$(this)
和,您可以选择仅包含在触发
.hover()事件的元素中的
.description
元素。有一个有效的例子。代码如下

$(document).ready(function() {
    $(".content").hover(function() {
        $(this).children(".description").fadeIn();
    }, function() {
        $(this).children(".description").fadeOut();
    });
});

你很接近。使用
$(this)
和,您可以选择仅包含在触发
.hover()事件的元素中的
.description
元素。有一个有效的例子。代码如下

$(document).ready(function() {
    $(".content").hover(function() {
        $(this).children(".description").fadeIn();
    }, function() {
        $(this).children(".description").fadeOut();
    });
});

这是一种方法

$(document).ready(function(){
    $(".content").hover(function(){
        $(this).children(".description").fadeIn(100);
    },function(){
        $(this).children(".description").fadeIn(100);
    });
});

希望这能有所帮助,这是一种方法

$(document).ready(function(){
    $(".content").hover(function(){
        $(this).children(".description").fadeIn(100);
    },function(){
        $(this).children(".description").fadeIn(100);
    });
});

希望这有帮助

这将在任何
内容中的所有
.description
中消失。OP只想在当前悬停的元素中淡入内容。是的,我没有想到这一点。你的答案比汉克斯好。问题有时可能有点神秘。我认为这一点的关键是
我的页面上有两个
。这将在所有
中消失。说明
在任何
中。内容
。OP只想在当前悬停的元素中淡入内容。是的,我没有想到这一点。你的答案比汉克斯好。问题有时可能有点神秘。我想这一个的关键是
我的页面上有两个
。非常感谢!工作完美!谢谢!工作完美!