Please explain to me why and why in this problem I get the parent of the button?
Dan input. Next to it is a button "+". By clicking on this button, another empty input should appear below our input.
var button = document.getElementById('button'); button.addEventListener('click', func); function func() { var parent = button.parentElement; var newInput = document.createElement('input'); parent.appendChild(newInput); } <input type="submit" value="+" id="button"> <input type="text">