I have the following:
<input type="text" id="tag_856_subfield_u_270150_676903" name="tag_856_subfield_u_270150_676903" value="http://www.test.com/2073-4441/8/1/23/pdf" class="input_marceditor noEnterSubmit" tabindex="1" size="67" maxlength="9999">
And I wanted to change the text input type into textarea by using the following jquery:
$('input[name^="tag_856_subfield_u"]').each(function () {
var style = $(this).attr('style'),
textbox = $(document.createElement('textarea')).attr('style', style);
$(this).replaceWith(textbox);
});
With the jquery above, I get to have a textarea but the data that is already in the text box is/are removed and inspecting the elements in Google Chrome, I only get the following:
<textarea></textarea>
Is there a way in jquery to do what I wanted to do as what can be seen below, such that I get the following below in my particular use case? The input id and input name is dynamic, hence I used input[name^="tag_245_subfield_b"]. I actually followed this stackoverflow question to achieve my use case: how to change an input element to textarea using jquery.
<textarea cols="70" rows="4" id="tag_856_subfield_u_270150_676903" name="tag_856_subfield_u_270150_676903" class="input_marceditor" tabindex="1">http://www.mdpi.com/2073-4441/8/1/23/pdf</textarea>
Thanks in advance and cheers!