I have a lot of input text input fields, which I want to replace with textarea if a person enters from the phone. How to replace, I know, but how do I transfer the data-answer parameters to the replaced textarea so that <textarea data-answer=""> would be obtained?
$(document).ready(function(){ $("input[type=text]").each(function(){ $(this).after('<textarea></textarea>').remove() }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <input type="text" data-answer="text 1"/> <input type="text" data-answer="text 2"/> <input type="text" data-answer="text 3"/>