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');
3
  • Have you wrapped your code in ready handler? Commented Nov 1, 2010 at 10:24
  • Don't do this: It causes problems. Remove and recreate the element instead. Commented Nov 1, 2010 at 10:24
  • 1
    what do you mean? This sounds like a bad idea anyway. Why would you want to change a submit button into a text field? What sense does that make? Commented Nov 1, 2010 at 10:31

1 Answer 1

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();
Sign up to request clarification or add additional context in comments.

3 Comments

jQuery forbids changing it because IE won't let you do it (webbugtrack.blogspot.com/2007/09/…) (and creating a workaround for this would be rather painful)
what do you use to check this restriction in Firebug. Which tab, section do you use to debug this problem?
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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.