I am trying a simple demo with requirejs and jquery for AMD. Following is my folder structure structure:
├── index.html
└── js
├── lib
│ ├── jquery.js
│ └── require.js
└── main.js
in my index.html file i have the following content:
<head>
<script data-main="js/main" src="js/lib/require.js"></script>
</head>
<body>
<div id="hello"> </div>
</body>
and my main.js file looks like this:
define(['lib/jquery'], function ($) {
$("#hello").html("Wow this works!");
});
But when i do, i get an error: Uncaught TypeError: undefined is not a function in main.js line 3.
What is wrong? I can't understand?
#hellodoes not exist at the time of script execution?require(['lib/jquery'], function ($) { $(function(){ $("#hello").text("Wow this works!"); }); });This also gives same error.