Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I did write a Code with JS trying to understand what is DOM in JS based on some online documentations and tutorials but its really not clear for me since begin a new in JS thus i have wrote a code do some basic staff and need an explanation
if someone could explain to me the DOM based on my code i will be so glad .

What I have tried:

<div id="david">Hello World</div>
<button id="clickMe" onclick="showmessage()">Click Me</button>
<P id ="GetArray"> </p>

<script>

function showmessage () {  
	var GetText = document.getElementById("david") ;
	if (GetText.innerHTML=="Hello World"){
		GetText.innerHTML="Hello FXXL";
	}else {
    GetText.innerHTML="Hello World";
	}
}
function SortArray (value) {

text += "<li>" + value+ "</li>";

}
var text = "<ul>";
var data = [
  "Microsoft",
  "Apple",
  "Google",
];
data.forEach(SortArray);
text += "</ul>";
document.getElementById("GetArray").innerHTML=text;
</script>
Posted
Updated 24-Sep-19 22:25pm
Comments
enhzflep 26-Sep-19 0:28am    
You can understand it by researching it, rather than asking lazy questions.

 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900