0

Who can explain what this code does in javascript

document.getElementById("paragraph").textcontent ="Hello, world";

24th Apr 2021, 7:53 PM
Micheal Alfred
3 Réponses
+ 2
If looks like you're trying to set the textContent of an element which has an id of "paragraph" to "Hello, world". It will do that as long as: * You run the JavaScript after the DOM has loaded. * You have an element which has a textContent property and has an id of "paragraph". * You change the property you're trying to set from textcontent to textContent.
24th Apr 2021, 8:14 PM
CamelBeatsSnake
CamelBeatsSnake - avatar
+ 1
This selects the Element with the ID "paragraph" from "document" and sets its textcontent to "Hello, world". After that will somewhere on your Website be shown: Hello, world"
24th Apr 2021, 8:22 PM
Coding Cat
Coding Cat - avatar
0
It's basically the text content , (what's written in it ), of the element with id "para". Like <div id="para" > Hello world </div> Hello world is it's text content
24th Apr 2021, 9:08 PM
Iyosayi0x
Iyosayi0x - avatar