self destruct button in html
Is it 开发者_如何转开发possible to destroy an html button. If it is clicked because it already served its purpose after clicking.
You can do so with JavaScript:
<button onclick="this.parentNode.removeChild(this)">Label</button>
Yes, it is possible, by using JavaScript to set its CSS property "display" to "none".
See also Seven ways to toggle an element with JavaScript.
I think you can do also by
<input type="button" onclick="this.style.visibility='hidden';">
Yes, you can disable or hide it. Example:
<input type="button" onclick="this.disabled=true;" />
However, if you do this to the submit button, it may not work properly. The value for the button will not be included in the form data, so if the server looks for the button data to find out what it was that caused the form to submit, it won't find it.
Yes you can do like this:
<input type="button" onclick="this.style.display = 'none';">
精彩评论