javascript - Replace an input with another dynamically created input -


this question has answer here:

i want replace existing file input field entirely text input field, properties intact id, name, etc. how do using jquery?

prelude:

i have <input type="file" name=".." id=".." /> using ajax based uploads. (yes, ie, submitting form using iframes.)

when upload done, go success callback function, trying change original <input type="file" <input type="text".

in other browsers, working fine when run following code:

$originalinput[0].type = 'text'; $originalinput[0].value = 'response code'; 

but not working in ie, came know security concern , hence not allowed. want write minimum code this.

from user2259571's answer, did following in shorter one-line way:

$originalinput     .replacewith( $originalinput[0].outerhtml.replace(/type="file"/, 'type="input"') ); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -