Pop Vlad
Pop Vlad

Reputation: 179

jquery fade in is not woriking

I can't make the the 'div' fade in when I click on 'a'.

CODE :

<!DOCTYPE html>
<html>
<head></head> 
 <body >
  <a>Click here</a>

  </div>
    <div id="js" style="display:none"> hahaha</div> 


<script type="text/javascript">
$(document).ready(function() {
  $('a').click(function() {
       $('div').fadeIn('slow',5000);
   });
});

  </script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  </body>
</html>

I tried also with 'css("display","block");' or toggle or if condition but it's still not woriking. By the way, I am new into Jquery. Please help me, thanks.

Upvotes: 0

Views: 71

Answers (1)

Pranav C Balan
Pranav C Balan

Reputation: 115222

You need to include jQuery library before your jQuery code

<a>Click here</a>
<div id="js" style="display:none">hahaha</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- code after including jQuery library -->
<script type="text/javascript">
  $(document).ready(function() {
    $('a').click(function() {
      $('#js').fadeIn('slow', 5000);
    });
  });
</script>

Upvotes: 1

Related Questions