JavaScript JavaScript and the DOM Making Changes to the DOM Creating New DOM Elements

Can anyone explain this?

At 3.02, line 25

li.textContext = addItemInput.value;?

Steve Hunter Steven Parker

1 Answer

Steven Parker
Steven Parker
187,062 Points

:bell: Hi, I got alerted by your tag. But there's many folks around who might help you, so for most questions you won't need to tag anyone specific. You can always add tags later if you don't get a good response after a while.

In this code, "addItemInput" is a reference to the text input control on the page, and the "value" property accesses what the user typed into it. This gets copied into the "textContent" attribute of the new list item element "li" that was created on the previous line.

At this point, nothing will happen that you can see, but in the next video more code will be added that will make changes to the page.