I want to remove a field from a form and not hide it because I want the form to retract when I hide the fields my form stays "wide" which is an aesthetic problem.
document.getElementById('test_field').style.visibility = "hidden";
it works but the form remains large (it only does the hidden)
I tried that but it doesn’t work
document.getElementById("test_field").style.display = "none";
edit: document.getElementById("test_field").remove() work thank you to "DaveS".
>Solution :
If display = "none" didn’t work for you, it sounds like you want it removed from the server’s point of view. In other words, you don’t want it to be submitted with the other fields. If that’s the case, you can just use document.getElementById("test_field").remove().