Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery fadeIn() not working

Description: I am trying to fadeIn() my container using jquery, but it doesn't work. I'm kinda new to it, only fresh out of codeacademy jquery course.

Problem: the method I wrote in myScript.js file doesn't seem to work. The syntax looks to be ok compared to other examples. I got my js file linked to the html file like this:

<script type="text/javascript" src="/Content/js/myScript.js"></script>

This is my index.cshtml file where I created a container for some navigation:

 <div class="container" id="fade">
        //some other buttons, divs, etc
 </div>

This is my custom js file that I included:

$(document).ready(function () {
    $('#fade').fadeIn('slow');
});
like image 313
Kelb56 Avatar asked Dec 25 '22 06:12

Kelb56


1 Answers

You should hide the div by default if you want to fade it in, otherwise it is already showing and fading in won't do anything. If that's the case, your html should look like this:

<div class="container" id="fade" style="display: none;">
    //some other buttons, divs, etc
</div>
like image 167
ZiNNED Avatar answered Jan 08 '23 21:01

ZiNNED