document.getElementById("demo") ; what is demo in this case??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

document.getElementById("demo") ; what is demo in this case???

5th Jul 2016, 9:10 AM
Thala Navin
Thala Navin - avatar
3 Answers
+ 6
The getElementById method gets an HTML element from your document with the specified ID, in this case "demo" in order to modify or apply style to it for instance. Example: <p id="demo">Some text.</p> <script> document.getElementById("demo").innerHTML = "New text."; </script> In this case, we want to change text for a paragraph with an ID "demo" (using .innerHTML).
5th Jul 2016, 1:03 PM
ZinC
ZinC - avatar
0
Demo links the javascript to the paragraph... it's just like class linking in css
5th Aug 2016, 7:23 AM
Peter
0
Demo is the name of an element id within your script for example <div id ="demo"> So your script is saying find the element called demo within your HTML page and then the following bit of script will be some kind of instruction or command saying what you would like to do with the element
13th Aug 2016, 4:14 PM
Nicholas Michael Rowe
Nicholas Michael Rowe - avatar