0

I need help with this code....it keeps on giving me this error....$ not defined: line 1

this is the html <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <input type="text" id="userInput"/> <div id="msg"></div> </body> </html> this is the jQuery $(function(){ $("#userInput").keydown(function (){ $("msg").html($("userInput").val()); }); });

23rd Apr 2017, 4:16 PM
Elijah Arhinful
Elijah Arhinful - avatar
6 Answers
+ 13
There's an error in your code. $('msg').html($('userInput').val()); should be $('#msg').html($('#userInput').val()); Don't forget to include jQuery.
23rd Apr 2017, 4:28 PM
Wisdom Abioye
Wisdom Abioye - avatar
+ 12
@Elijah, you need to include jQuery. Use the link @Rob Howard posted.
23rd Apr 2017, 6:25 PM
Wisdom Abioye
Wisdom Abioye - avatar
+ 1
You need to include jQuery file in the HTML code.
23rd Apr 2017, 4:19 PM
Raj Sharma
+ 1
You can add this somewhere between <head> & </head>: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
23rd Apr 2017, 4:29 PM
Rob Howard
Rob Howard - avatar
0
I am using the sololearn code playground on my fone so I thought it wasn't necessary to include jQuery
23rd Apr 2017, 5:51 PM
Elijah Arhinful
Elijah Arhinful - avatar
0
thank you guys
23rd Apr 2017, 5:52 PM
Elijah Arhinful
Elijah Arhinful - avatar