Is it possible to destroy an html button. If it is clicked because it already served its purpose after clicking.
+2
A:
Yes, it is possible, by using JavaScript to set its CSS property "display" to "none".
littlegreen
2010-01-25 13:20:14
+8
A:
You can do so with JavaScript:
<button onclick="this.parentNode.removeChild(this)">Label</button>
Gumbo
2010-01-25 13:20:44
parent**Node**.
bobince
2010-01-25 13:23:36
Ah, damn. Thanks, @bobince.
Gumbo
2010-01-25 13:42:40
+1
A:
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.
Guffa
2010-01-25 13:22:48
But this doesn't happen if you hide the button using display = none.
littlegreen
2010-01-25 13:26:17
@littlegreen: That may be browser dependant, so I wouldn't rely on it. I remember having problems with Netscape not sending data from invisible fields...
Guffa
2010-01-25 14:11:49
+1
A:
Yes you can do like this:
<input type="button" onclick="this.style.display = 'none';">
Sarfraz
2010-01-25 13:23:16