简体   繁体   English

我的jQuery代码有什么问题? 我想让div淡入

[英]What is wrong with my jQuery code? I want a div to fade in

I recently started learning some jQuery. 我最近开始学习一些jQuery。 I want to fade in a div but nothing is happening. 我想淡入一个div,但是什么也没发生。 Can someone please tell me what is wrong? 有人可以告诉我怎么了吗?

Everthing is linked so that's not the problem: 一切都链接在一起,所以这不是问题:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
    <script src="inc/content_animate.js"></script>

content_animate is my .js file. content_animate是我的.js文件。 This is in it: 在其中:

$(document).ready(function(){
    $('.content').fadeIn('fast');
});

I want to fade in my .content div. 我想淡入.content div。 Which is this: 这是什么

<div class="content">
  <img src="img/design.svg">
  <h2>Design</h2>
  <p>I don't only program my websites. I also design my websites myself.</p>
  <a class="btn-content" href="projects.php">Learn more</a>
</div>

What did I do wrong? 我做错了什么? Thanks in advance to everyone looking into this! 预先感谢大家对此进行调查!

your code is fine, but if you dont hide your div initially, theres nothing to fade in, because its already showing. 您的代码很好,但是如果您最初不隐藏div,则没有任何内容可以淡入,因为它已经显示。

 $(document).ready(function() { $('.content').fadeIn('slow'); }) 
 .content { display: none; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="content"> <img src="img/design.svg"> <h2>Design</h2> <p>I don't only program my websites. I also design my websites myself.</p> <a class="btn-content" href="projects.php">Learn more</a> </div> 

$(".content").hide().fadeIn('fast')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM