New course! Every coder should learn Generative AI!
Try a free lesson+ 2
Am typing in "document.getElementByld()" but the browser keeps returning "type error: document.getElementByld()" is not a functi
5 Answers
+ 2
Were you typing an L? because i and L use the same character and can be confusing.
i = I
L = l
+ 11
Can you attach the link to code here? 😅
+ 3
There could be a few issues here
Here are possible solutions:
1. Javascript loads before the DOM, so surround whatever is being called right away with window.onload { //your code here}
2. You possibly forgot quotes in getElementById()
Like this:
getElementById("MyElement");
3. You forgot the word "document".
document.getElementById("MyElement")
4.You're trying to get a class with getElementById(). To grab a class, use getElementsByClassName("Example")[1]
[1] represents the class. Since there can be multiple classes, you can use this to get a specific one.
5. You spelled the id wrong. Pretty sure we've all done this.
6. you forgot quotes in the HTML id deceleration. I've done this.
+ 1
Martin Mururu Did you ever get this figured out?
0
all that time ive been thinking its Byld(with an "l")🤦🤦