简体   繁体   中英

How to delete piece of HTML using JavaScript

I have a form and I want it to not be displayed on submit - how is this possible? :)

<body>
<form method="POST" action="test.php" name="_navn">
<input name="txt" id="input" type="text" value="Write here" onFocus="noValue()" onBlur="changeValue()">
<input type="submit" value="Submit">
<input type="hidden" name="_submit_check" value="1">
</form>
</body>

This is what I want to go away when the hidden input is submitted. How? :)
(the <body> -tags are not part of what I want to be deleted hehe)

you just want the form and everything in it off the page?

var f = document.getElementsByTagName('form')[0];
f.parentNode.removeChild(f);

otherwise you can just hide it with

f.style.visibility = 'hidden'

or

f.style.display = 'none';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM