I’ve looked at all the similar posts regarding Uncaught error: $is not defined and nothing has helped. I have the latest jquery library and just not understanding why this error is showing.
$(function() {
// Checking for CSS 3D transformation support
$.support.css3d = supportsCSS3D();
var formContainer = $('#formContainer');
$('.flipLink').click(function(e){
// Flipping the forms
formContainer.toggleClass('flipped');
if(!$.support.css3d){
$('#login').toggle();
}
e.preventDefault();
});
formContainer.find('form').submit(function(e){
e.preventDefault();
});
function supportsCSS3D() {
var props = [
'perspectiveProperty', 'WebkitPerspective', 'MozPerspective'
], testDom = document.createElement('a');
for(var i=0; i<props.length; i++){
if(props[i] in testDom.style){
return true;
}
}
return false;
}
});
I’m calling the script here as scripts.js
<head>
<script type="text/javascript" src="js/scripts.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<link rel = "stylesheet" href= "css/styles.css">
</head>
I would very appreciative to get the knowledge to understand why this happened in this situation and any tips as well.
Include your script after jQuery, not before.
Browsers evaluate
<script>tag contents as soon as they’re loaded, incrementally. If you put yours first, the browser will attempt to run it before even parsing the subsequent scripts. Thus, your script’s dependencies won’t be satisfied and you’ll get errors like that.