Why is jQuery not working in the JavaScript section of SoloLearn? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why is jQuery not working in the JavaScript section of SoloLearn?

For some reason, SoloLearn won’t let me use jQuery unless I open up a <script> tag I the HTML. Oh, and by the way. https://code.sololearn.com/WmBL08hEGpBY/?ref=app

16th Dec 2018, 11:22 AM
Ojani
Ojani - avatar
11 Answers
+ 3
In jQuery, it is $(document).ready(function(){ ... } Shorthanded : $(function() { ... } Which are in second and third page in the "getting started" above. Reason is, js tab scripts are put in head and compiled before body. Your way of putting js script before end of body is another way ensure successing DOM assignment.
16th Dec 2018, 11:42 AM
Gordon
Gordon - avatar
+ 3
Jquery works in the JavaScript section. See this : https://code.sololearn.com/Wm198S0Ra8Xc/?ref=app
16th Dec 2018, 11:28 AM
Arushi Singhania
Arushi Singhania - avatar
+ 2
Yes that is importing library.
16th Dec 2018, 11:29 AM
Gordon
Gordon - avatar
+ 2
You are referencing DOM Have you wrap your js codes in window.onload when you put your scripts in the JS tab?
16th Dec 2018, 11:32 AM
Gordon
Gordon - avatar
+ 2
I am sorry too. I misunderstood your question in the first place.
16th Dec 2018, 11:43 AM
Gordon
Gordon - avatar
+ 1
https://www.sololearn.com/learn/jQuery/2785/ I checked your profile. You have completed jQuery course so you should know that you must import the jQuery library in order for the jQuery syntax to function. Please do not spam the Q&A section. Thanks Not to do on Sololearn Q&A https://code.sololearn.com/W26q4WtwSP8W/?ref=app
16th Dec 2018, 11:27 AM
Gordon
Gordon - avatar
+ 1
Gordon I am including it in my head.
16th Dec 2018, 11:28 AM
Ojani
Ojani - avatar
+ 1
Arushi Singhania It used to work like that for me but it doesn’t anymore.
16th Dec 2018, 11:29 AM
Ojani
Ojani - avatar
16th Dec 2018, 11:34 AM
Gordon
Gordon - avatar
+ 1
Gordon Thank you! It worked after the code was wrapped with the “$(function(){...})” . :) I’m sorry, I can delete the thread if you please.
16th Dec 2018, 11:41 AM
Ojani
Ojani - avatar
0
Gordon I just said that I have imported the library but it only lets me use jQuery if I open up a script tag in the HTML.
16th Dec 2018, 11:33 AM
Ojani
Ojani - avatar