On Chromium 7.0.517.44 (64615) Ubuntu 10.10, I seem to be unable to change the type
attribute of a <button>
element:
> blah = document.createElement("button")
<button></button>
> blah.type
"submit"
> blah.type = "button"
"button"
> blah.type
"submit"
Help?
On Firefox 3.6.12 and Opera 10.63, it works fine:
>>> blah = document.createElement("button")
<button>
>>> blah.type
"submit"
>>> blah.type = "button"
"button"
>>> blah.type
"button"
Use setAttribute
.
blah.setAttribute('type', 'button');
Change the type
attribute on any of the input family generally doesn't work (I know for a fact it does not work on input
).
What you may want to do is clone the element, replace the type
attribute whilst the HTML is serialised and then append it after. Then delete the original.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With