so i found this thread, but I can't figure out how to actually call the functions.
i have tried:
removeRow('message')
and
removeRow(document.getElementById('message'))
i am using the accepted answer and my html is
<form action="http://localhost/signup.php" method="post" style="display:inline-block; margin:0 auto;">
<label for="username">Username</label>
<br>
<input type="text" name="username" id="username" placeholder="Username" required>
<br>
<label for="password">Password</label>
<br>
<input type="password" name="password" id="password" placeholder="Password" onkeyup='check();' required>
<br id="message">
<p id="message"></p>
<br id="message">
<label for="confirm_password">Confirm Password</label>
<br>
<input type="password" name="confirm_password" id="confirm_password" placeholder="Password" onkeyup='check();' required>
<br>
<label for="Email">Email Address</label>
<br>
<input type="email" name="email" id="email" placeholder="Email" required>
<button type="submit" id="signup">
Sign up
</button>
</form>
1 Answer 1
The function in the original answer is :
function removeRow(input) {
input.parentNode.remove()
}
So the expected parameter of the function is an element and the function removes element's parent. If you want to remove the element with id #message, just change the function to:
function removeRow(element) {
element.remove()
}
PS: the ids should be unique, if you have multiple element with the same you should use a class
and the selector will be document.getElementsByClassName("message")
answered Nov 22, 2022 at 23:02
voidbrain
3921 gold badge3 silver badges15 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default
ptag by executing theremoveRowfunction?