jQuery is not work in script.js | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

jQuery is not work in script.js

Hi guys, On script.js, I wrote this code : $(document).ready(function () {     // jQuery code here }); when I execute the code. It does not work. Thank you.

5th Jul 2018, 8:21 PM
program
program - avatar
3 Answers
+ 2
Full Gamer I tried on my computer but it does not work anyway.
5th Jul 2018, 10:40 PM
program
program - avatar
+ 1
Full Gamer No it's not that. It's because of document ready.
5th Jul 2018, 9:22 PM
program
program - avatar
+ 1
Zohir what do you mean "because of document ready"? first of all you need the jquery library. also you need the block of instructions to be inside a <script> tag because in this way your browser knows that is a script. and the last thing, jquery needs document.ready or load or onload. it depends what you want to do ... but also if you don't include the .js file in .html head file, your code inside .js file wont run. cheers
10th Jul 2018, 8:44 PM
Catalin Popinciuc
Catalin Popinciuc - avatar