0

Possible Duplicate:
jQuery change input type

How to replace input[type=submit] to input[type=text] using jQuery?

This way does't work:

$('input[type=submit]').removeAttr('type').attr('type','text');
Community
  • 1
  • 1
Algorithm
  • 329
  • 6
  • 16

1 Answers1

6

You can't change that property type (don't know why but that is what firebug logs), so the best thing you can do is to totally remove the input-element and insert a new input with the correct type.

Use jQuery with something like this:

$('input[type=submit]').after("<input type='text' />");
$('input[type=submit]').remove();
Justus Romijn
  • 15,699
  • 5
  • 51
  • 63
  • 1
    jQuery forbids changing it because IE won't let you do it (http://webbugtrack.blogspot.com/2007/09/bug-237-type-is-readonly-attribute-in.html) (and creating a workaround for this would be rather painful) – scunliffe Nov 01 '10 at 10:32
  • what do you use to check this restriction in Firebug. Which tab, section do you use to debug this problem? – Yasen Zhelev Nov 01 '10 at 10:33
  • I see it in the console tab. I've made a JsFidde to test this, and there you can see the log stating it : [jsFiddle firebug log error when changing type attribute](http://jsfiddle.net/fXR44/1/) – Justus Romijn Nov 01 '10 at 10:35