Dont know the Error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Dont know the Error

Just look at the Javascript of this code https://code.sololearn.com/WM13v7WVrqb7/?ref=app

25th Jan 2018, 12:08 PM
Michelle Becker
Michelle Becker - avatar
10 Answers
+ 1
Document wird klein geschrieben, auf innerHTML folgt ein = und keine Klammer. innerHTML ist eine Eigenschaft von HTMLElement, keine Funktion.
25th Jan 2018, 12:46 PM
SplittyDev
SplittyDev - avatar
+ 18
i wrote a comment, look
25th Jan 2018, 12:28 PM
\__(° = °)__/
+ 5
1. change function name from "click()" to anything else, may be click is already preserved keyword or something. 2. use small 'd' in document, instead of Document. 3. innerHTML is not a function, so don't use parantheses, it should be: document.getElementById("Knorpf").innerHTML=x++;
25th Jan 2018, 12:22 PM
Harjeet Singh
Harjeet Singh - avatar
+ 2
You're welcome. I usually write in English, but your code looked like German (Knopf :D) so I figured I could answer in German and make it a bit easier for you
25th Jan 2018, 3:29 PM
SplittyDev
SplittyDev - avatar
+ 2
Javascript is case sensitive language...Document !=document.The event for button click is onClick()..you did not even put semi color after declearing variable..document.getElementById("example").innerHTML=count_variable++; as inner.HTML is not function.If applied should run fine
25th Jan 2018, 3:31 PM
Sunil Thakali
Sunil Thakali - avatar
+ 1
Thanks to all guys but special for you Splitty Dev, , because youve written in German and thats my mother language
25th Jan 2018, 3:27 PM
Michelle Becker
Michelle Becker - avatar
+ 1
@Sunil Thakali, HTML is case insensitive, so onclick or onClick doesn't make a difference. The onClick function in Javascript is a custom one, not a case sensitive event handler, so that doesn't cause problems either. Also, semicolons are optional in most cases, there are actually very few cases where a semicolon is needed.
25th Jan 2018, 3:35 PM
SplittyDev
SplittyDev - avatar
+ 1
did you read carefully my comment carefully...i said javascript is case sensitive so do not use Document instead of document.i said the event handler is onclick.not click.usually we use camel case for better readibility..and where do you not use semicolon for declearing variables in javascript..
25th Jan 2018, 3:44 PM
Sunil Thakali
Sunil Thakali - avatar
+ 1
Take a look at https://standardjs.com Few people know this, but you can write Javascript code without semicolons in the vast majority of cases. You can declare a variable just fine without using a semicolon.
25th Jan 2018, 3:48 PM
SplittyDev
SplittyDev - avatar
+ 1
tx for great info..i must have been using semi-standard up to now...
25th Jan 2018, 3:55 PM
Sunil Thakali
Sunil Thakali - avatar