0

Why doesnt it work

i thought i did it good, can someone please explain why and what doesnt work, and how to correct the mistake. https://code.sololearn.com/WuU3yGBHAGLO/?ref=app

15th May 2018, 2:43 PM
Roel
Roel - avatar
14 Réponses
+ 1
You are selecting the element before it is ready. Put the var "pts =" in the onload but keep the "var pts" outside so that it gets created in the window scope.
15th May 2018, 3:10 PM
Nommer101
Nommer101 - avatar
+ 1
hi, @roel ----------------- i have refreshed your code try this url :- ----------------------------- https://code.sololearn.com/WCdw9Y41n6FR
15th May 2018, 3:19 PM
Rajeeb
0
Thanks, it works now
15th May 2018, 3:11 PM
Roel
Roel - avatar
0
Rajeeb thanks, but i already corrected my mistake: https://code.sololearn.com/WuU3yGBHAGLO/?ref=app
15th May 2018, 3:21 PM
Roel
Roel - avatar
0
Nommer101 did the exact same thing with var upmpc, but it seem to give the error (upmpc is not defined)
15th May 2018, 4:24 PM
Roel
Roel - avatar
0
Roel $(function(){ is the same as onLoad but its running before onload is running.
15th May 2018, 4:29 PM
Nommer101
Nommer101 - avatar
0
try my code @roel from rajeeb
15th May 2018, 4:32 PM
Rajeeb
0
Roel Its actually your code is getting declared in a scope so the variable dies after onload executes. Put var upmpc with other variables.
15th May 2018, 4:32 PM
Nommer101
Nommer101 - avatar
0
Rajeeb I'll see what parts can make my code better, and what parts i want to keep because my brain says it
15th May 2018, 4:36 PM
Roel
Roel - avatar
0
btw thanks for the tip Rajeeb and thanks for the help with upmpc Nommer101
15th May 2018, 4:37 PM
Roel
Roel - avatar
0
Roel innerHTML is not a jquery property. Use text (""), val ("") or html ("")
15th May 2018, 4:41 PM
Nommer101
Nommer101 - avatar
0
Nommer101 then why does it work with wallet?🤔🤔
15th May 2018, 4:48 PM
Roel
Roel - avatar
0
Roel Probably because you selected by ID or you have a newer version of jquery. Or I'm just wrong 😅
15th May 2018, 4:49 PM
Nommer101
Nommer101 - avatar
0
nah, ill just use the good old trusted way: document.getElementById("").innerHTML. might be longer, but it works
15th May 2018, 4:51 PM
Roel
Roel - avatar