Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - "fadeIn is not a function"

Running into a very strange problem. Trying to run fadeIn() but I am getting the error ".fadeIn is not a function".

My code:

body {    display:none;  }
<!DOCTYPE html>  <html lang="en">    <head>      <!-- Required meta tags -->      <meta charset="utf-8">      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">        <!-- Bootstrap CSS -->      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">        <link rel="stylesheet" href="css/custom.css">    </head>    <body>      Test        <!-- Optional JavaScript -->      <!-- jQuery first, then Popper.js, then Bootstrap JS -->      <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>        <script type="text/javascript">        $(document).ready(function(){          $('body').fadeIn();        })      </script>    </body>  </html>

Error message:

"TypeError: $('body').fadeIn is not a function. (In '$('body').fadeIn()', '$('body').fadeIn' is undefined)" 

Using Bootstrap v4 beta, tested locally on Chrome and Safari.

like image 907
user3183717 Avatar asked Aug 12 '17 01:08

user3183717


1 Answers

The default template for Bootstrap 4 uses th "slim" version of jQuery which doesn't include many functions. You need to switch back to using a more featured version. For example:

body {    display:none;  }
<!DOCTYPE html>  <html lang="en">    <head>      <!-- Required meta tags -->      <meta charset="utf-8">      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">        <!-- Bootstrap CSS -->      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">        <link rel="stylesheet" href="css/custom.css">    </head>    <body>      Test        <!-- Optional JavaScript -->      <!-- jQuery first, then Popper.js, then Bootstrap JS -->      <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>        <script type="text/javascript">        $(document).ready(function(){          $('body').fadeIn();        })      </script>    </body>  </html>
like image 191
DavidG Avatar answered Sep 18 '22 12:09

DavidG