/    Sign up×
Community /Pin to ProfileBookmark

Uncaught TypeError: Document.getElementById is not a function

I’m new to this forum and very new to web development. I just picked up a first project for practice.
I faced a problem. the Error is : **Uncaught TypeError: Document.getElementById is not a function
at HTMLButtonElement.<anonymous>**

**my js code is :**
document.getElementById(‘add’).addEventListener(‘click’, function() {
let value = Document.getElementById(‘item’).value;
if (value) addItemTodo(value); });

function addItemTodo(text) {
let list = document.getElementById(‘todo’);
let item = document.createElement(‘li’);
item.innerText = text;
let buttuns = document.createElement(‘div’);
buttuns.classList.add(‘buttuns’);

**and my HTML code is:**
<body>
<header>
<input type=”text” placeholder=”Enter your favorite food …” id=”item”>
<button id=”add”>
<svg height=”30.33333pt” viewBox=”0 0 400.33333 550.33333″ width=”30.33333pt” xmlns=”http://www.w3.org/2000/svg“>
<g >
<path class=’fill’
d=”m437.332031 192h-405.332031c-17.664062 0-32 14.335938-32 32v21.332031c0 17.664063 14.335938 32 32 32h405.332031c17.664063 0 32-14.335937 32-32v-21.332031c0-17.664062-14.335937-32-32-32zm0 0″/><path d=”m192 32v405.332031c0 17.664063 14.335938 32 32 32h21.332031c17.664063 0 32-14.335937 32-32v-405.332031c0-17.664062-14.335937-32-32-32h-21.332031c-17.664062 0-32 14.335938-32 32zm0 0″/></g>
</svg>
</button>
</header>

<div class=”container”>
<!–uncompleted task–>
<ul class=” todo ” id=”todo”>


to post a comment
HTMLJavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@cootheadSep 07.2020 — Hi there saraeeeiiiii,

[b]D[/b]ocument should be [b]d[/b]ocument. 😀

[i]coothead[/i]
Copy linkTweet thisAlerts:
@saraeeeiiiiiauthorSep 08.2020 — Hi 👋🏿 tnx 😂
Copy linkTweet thisAlerts:
@cootheadSep 08.2020 — No problem, you're very welcome. ;)

[i]coothead[/i]
Copy linkTweet thisAlerts:
@VITSUSASep 09.2020 — @saraeeeiiiii#1623073 I agree with Coothead, as a fresher this type of mistake happens, so try to focus on a syntax error, capital, and small letters as well.
×

Success!

Help @saraeeeiiiii spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...