javascript - Replace an input with another dynamically created input -
this question has answer here:
- change type of input field jquery 26 answers
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 iframe
s.)
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
Post a Comment