Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

how to display an array in html

<p id="display-array"></p>
<script type="text/javascript">
	// array to be displayed
	var array = [1, 2, 3, 4, 5];
	// access the textContent of the HTML element and set it to the
	// value of the array with each element seperated by a comma and a space
	document.getElementById("display-array").textContent = array.join(", ");
</script>
 
PREVIOUS NEXT
Tagged: #display #array #html
ADD COMMENT
Topic
Name
4+3 =