如何使用jQuery隐藏

时间:2017-05-25 23:29:56

标签: javascript jquery function

大家晚上好,

我是jQuery的新手,我在使用hide()函数时遇到了麻烦。我按照指示完成了代码,但我似乎仍有问题。

谢谢你, 编

$(document).ready(function () {
    'use strict';
    $("p.class-text").on("mouseover", function () {
        $(this).fadeOut(5000);
    });
    
});
<div class="card">
    <a href="http://www.castro4designs.com" target="_blank"><img src="img/home.png" height="240" width="356" alt="4Design Home Page"></a>
    <p class="card-text">Castro4design.com was my first official website which was done for my 'Intro to New Media Tech' class. The site consist of basic HTML and CSS. The site was to keep track of all our work throughout our college career.</p>
</div>

2 个答案:

答案 0 :(得分:3)

您的p课程class-text <{1}}已经没有p课程card-text

使用$("p.card-text")代替$("p.class-text")

答案 1 :(得分:0)

你应该使用相同的类名:&#34; card-text&#34;例如。还在您的代码段中添加了jQuery标记。

&#13;
&#13;
$(document).ready(function () {
    'use strict';
    $("p.card-text").on("mouseover", function () {
        $(this).fadeOut(1000);
    });
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="card">
    <a href="http://www.castro4designs.com" target="_blank"><img src="img/home.png" height="240" width="356" alt="4Design Home Page"></a>
    <p class="card-text">Castro4design.com was my first official website which was done for my 'Intro to New Media Tech' class. The site consist of basic HTML and CSS. The site was to keep track of all our work throughout our college career.</p>
</div>
&#13;
&#13;
&#13;