logo

Crowdly

Browser

Додати до Chrome

\n\n

Alice

\n \n \n","dateCreated":"2026-06-01T07:03:11.986729+00:00","eduQuestionType":"Multiple choice","answerCount":4,"acceptedAnswer":[],"suggestedAnswer":[{"@type":"Answer","text":"getElementById uses the wrong id","upvoteCount":0,"dateCreated":"2026-06-01T07:03:11.986729+00:00"},{"@type":"Answer","text":"The script runs before the HTML element has been parsed","upvoteCount":0,"dateCreated":"2026-06-01T07:03:11.986729+00:00"},{"@type":"Answer","text":"JavaScript cannot access text content of HTML elements","upvoteCount":0,"dateCreated":"2026-06-01T07:03:11.986729+00:00"},{"@type":"Answer","text":"The

element should be inside the ","upvoteCount":1,"dateCreated":"2026-06-01T07:03:11.986729+00:00"}]}},{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Університети","item":"https://crowdly.sh/uk/domains/"},{"@type":"ListItem","position":2,"name":"www.moodle.aau.dk","item":"https://crowdly.sh/uk/domains/www_moodle_aau_dk/"},{"@type":"ListItem","position":3,"name":"Internetworking and Web-programming (IWP) (DAT2, AAL-SW2, BaIT6T)","item":"https://crowdly.sh/uk/domains/www_moodle_aau_dk/courses/58803/"},{"@type":"ListItem","position":4,"name":" \n A developer wrote the following inside an HTML document, and expects the text \"Alice\" to appear in the console. However, when it is loaded into the browser the console shows an error instead. What is the most likely reason? \n \n ... \n \n ... \n \n\n

Alice

\n \n \n","item":"https://crowdly.sh/uk/question/c1c7d162b9964523c50e612bc2410d7bb79fea3f44113d62c2acf6054b004b95/"}]}]}

A developer wrote the following inside an HTML document, and expects the text...

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

A developer wrote the following inside an HTML document, and expects the text "Alice" to appear in the console. However, when it is loaded into the browser the console shows an error instead. What is the most likely reason?

...

<body>

...

<script>

const name = document.getElementById("username").textContent;

console.log(name);

</script>

<p id="username">Alice</p>

</body>

0%
0%
0%
100%
Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на www.moodle.aau.dk?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome