[SOLVED] Onclick not working | Sololearn: Learn to code for FREE!


[SOLVED] Onclick not working

https://code.sololearn.com/WA5A7a16a102/?ref=app When we click at the box in the app it works perfectly But when we try to run the same code on laptop (website) it doesn't work :(

4/22/2021 4:33:10 PM

Namit Jain

12 Answers

New Answer


David Dolejší It appears that SL is using the IIFE (website only) to solve the problem you were referring to in your first response to this post, but doing so has caused Namit Jain [INACTIVE] issue/bug where the function func is not globally scoped as it would normally be without the IIFE, see Sofi (DM Closed❌) 's code. Another way to solve this is to use a function expression instead of function declaration, ex window.func = function(){...}.


Is it working now? https://code.sololearn.com/WWdXvavSbp3N/?ref=app


for me all codes on web sl works only if I run first time, then it throws error :D so I dont use sl on pc at all to your question, the event worked but it called the function isnt defined...


Namit Jain [INACTIVE] welcome😁


Thank you so so much Sofi (DM Closed❌) 🙏🙏 I have been stuck on it for more than 2 hours. And now it's working perfectly 😃


I thought you were researching why the first case doesnt work 😂


Ohh, I should have elaborated my question better. But Sofi (DM Closed❌) understood the problem and came up with the solution Thanks to her again :)


Yeahh same :(


Ohh I see 🧐🤔 Thanks for that! 👍✌


ODLNT that worked! Thank you so much✌:) I wish we had the option to mark 2 answers as best...


Namit Jain [INACTIVE] wlcm again😆


Itha konjam soldra punda