Why this Returns to Definde 💔 ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why this Returns to Definde 💔 ?

var x = $("div").text(); Consle.log(x); <div>10</div>

28th Apr 2019, 2:19 AM
Omar Khalil Bakhsh
Omar Khalil Bakhsh - avatar
3 Answers
28th Apr 2019, 3:02 AM
Omar Khalil Bakhsh
Omar Khalil Bakhsh - avatar
- 1
You are calling the DOM selector code before your html document is read. put the script after the those element or wrap it onload window.onload = function(){ //js code }
28th Apr 2019, 2:51 AM
Lord Krishna
Lord Krishna - avatar
- 1
Yeah, hello is not definied. Quote it or define a function/variable named hello. Like "Hello" Or var hello = "my variable named hello" On a side note please share direct links to codes. Those short links are an unneccesary redirect and shoudn't be trusted.
28th Apr 2019, 3:07 AM
Lord Krishna
Lord Krishna - avatar