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

+8

[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

+2

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(){...}.

+10

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

+6

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...

+5

Namit Jain [INACTIVE] welcome😁

+3

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 😃

+3

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

+3

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 :)

+2

Yeahh same :(

+1

Ohh I see 🧐🤔 Thanks for that! 👍✌

+1

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

+1

Namit Jain [INACTIVE] wlcm again😆

-1

Itha konjam soldra punda