+ 3
Why clearInterval(start) and clearTimeout(a) is not working? Please help me
I have made this code like a celebration of finishing JavaScript Tutorial course, but clearInterval and clearTimeout didn't work with me when the player clicks on "Click here" . https://code.sololearn.com/WrM57oUS98L5/?ref=app
6 ответов
+ 3
Runs fine for me?
Are you getting errors? What exactly are you seeing on your end?
+ 2
Can you copy/paste the error and line number? It runs without a problem on my side from SoloLearn. If you're getting error though, I can help you figure out why you're getting it on your end.
+ 2
@Andrew Girder I tried that and it didnt work, he wud have to call all of his click functions thru addEventListener in the window onload I think to make that work
@thequestion I think the problem here is you shud set the document.getElementById("yourPelement") piece of the code to a variable,
ie.
in the JS tab
var p1, p2, p3, p4, p5; (etc)
in the window.onload = function(){}
or in <script> tags right before the closing </body> tag.
p5 = document.getElementById("p5").innerHTML; (etc)
then rewrite ur script using the variables. they shud be assigned to the DOM after it loads.
+ 1
syntax error can't set property of innerHTML
+ 1
Uncaught TypeError:Cannot read property 'innerHTML' of null.
line:3 and 6 and 9 and 12 and 15 and 22 and 26 and 30 and 34 and 38 and 42 .
at every innerHTML to "" to make them empty .. but I made a clearTimeout and clearInterval.
- 1
? Idk bro....
@Andrew
according to w3schools id syntax:
"Must contain at least one character
Must not contain any space characters
In HTML, all values are case-insensitive"
Doesn't say no numbers. I use numbers in id in my codes, they work.