the problem is i want the result like this
but it does not show it
what i want is to make a program that show names on webpage as i add them through the input box using array
it’s a very easy program but i don’t whay do i get this error
This is the code :
var students = [];
document
.getElementById("add-student-btn")
.addEventListener("click", function() {
var SNNA1me = document.getElementById("student-input").value;
student.push(SNNA1me);
document.getElementById("students").innerHTML = students;
});
<div style="text-align: center; margin-top: 100px">
<input type="text" id="student-input" />
<button id="add-student-btn">Submit</button>
<div id="students" style="font-size: 30px"></div>
</div>
2
Answers
student.push(SNNA1me)
should bestudents.push(SNNA1me)
Because your
student
is undefinedCorrection should be