Why doesn't the click me button work correct | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why doesn't the click me button work correct

If you buy one the money buttons, nothing happens, can anyone find whats wrong in my code? https://code.sololearn.com/WuU3yGBHAGLO/?ref=app

19th May 2018, 5:50 PM
Roel
Roel - avatar
34 Answers
+ 1
Roel You forgot the # to tell jquery that its an id. so it is looking for tags named mb1 mb2 ect instead of an tag with an id mb1 mb2 ect.
19th May 2018, 6:55 PM
Nommer101
Nommer101 - avatar
+ 1
I don't know nearly enough jQuery to answer your question, but thats a really nice website you've made! Props to you!
19th May 2018, 6:00 PM
Just A Rather Ridiculously Long Username
+ 1
Good job! One question, did you come up with all of the design on your own or were you inspired from somewhere else?
19th May 2018, 6:51 PM
Just A Rather Ridiculously Long Username
0
Just A Rather Ridiculously Long Username thanks very much, its my first real project
19th May 2018, 6:01 PM
Roel
Roel - avatar
0
Just A Rather Ridiculously Long Username The idea of making a clicker game was "stolen" from Cookie Clicker, but to make it look totally grey and let the style be buyable was my idea. I totally designed it from my head, even though it did look a bit different than in my head
19th May 2018, 10:53 PM
Roel
Roel - avatar
0
but i still want to learn how to add storage, because now if you are very far in my game, and you clicking on html/css/js once, you have to start from 0 again
19th May 2018, 10:57 PM
Roel
Roel - avatar
0
Roel Unfortunately on sololearn you cannot use localStorage, indexedDB, or webSQL because they are running the webview in the about:blank context. I can try create an work around if you want to do it or you can host your game which would provide you with a context you can use.
20th May 2018, 7:14 AM
Nommer101
Nommer101 - avatar
0
Nommer101 but, in case i put it in a html file on my pc, could it use localStorage then, or do i have to host it
20th May 2018, 8:06 AM
Roel
Roel - avatar
0
Roel It works on file://. Its simple: localStorage.setItem ('money',100); localStorage.getItem ('money');
20th May 2018, 9:50 AM
Nommer101
Nommer101 - avatar
0
so if i do that and send it to a friend, he can save it on his pc too?
20th May 2018, 10:11 AM
Roel
Roel - avatar
0
Yes, it will save on the browser so if you use the same browser. Meaning if he plays the game on chrome and then closes it and open it on chrome again on the same pc then he can load the data.
20th May 2018, 11:41 AM
Nommer101
Nommer101 - avatar
0
Nommer101 is it possible to dont save a pre defined number, something like this: localStorage.setItem('cash',money); to set the value of storage 'cash' to the current amount of money?
20th May 2018, 2:55 PM
Roel
Roel - avatar
0
Roel Yes, thats how it works.
20th May 2018, 3:02 PM
Nommer101
Nommer101 - avatar
0
Nommer101 thank you very much, that will help a lot in all of my upcoming gaming projects and other projects that need to be saved
20th May 2018, 4:59 PM
Roel
Roel - avatar
0
Nommer101 and i guess its possible to do all the localStorage.getItem's in the window.onload and all the localStorage.setItem's in a save progress button
20th May 2018, 5:02 PM
Roel
Roel - avatar
0
Roel Yes, however you want to use it. You can even have a load button or you could save every minute or second.
20th May 2018, 5:05 PM
Nommer101
Nommer101 - avatar
0
tnx
20th May 2018, 5:06 PM
Roel
Roel - avatar
0
Nommer101 how does it work with defining variables, if i do this: window.onload=function(){ localStorage.getItem('money'); } var money = 0; vat t = setInterval(save, 1); function save(t){ localStorage.setItem('money',money); } does var money = 0; overwrite the localStorage? Hope there'll come more advanced storage lessons in javascript
20th May 2018, 5:42 PM
Roel
Roel - avatar
0
money = localStorage.getItem ('money');
20th May 2018, 6:11 PM
Nommer101
Nommer101 - avatar
0
thx
20th May 2018, 6:55 PM
Roel
Roel - avatar