I have the following html:
<div>
<input type="text" style="xxxx" size="40"/>
<input type="text" style="xxxx" size="100"/>
<input type="text" style="xxxx" size="100"/>
<input type="text" style="xxxx" size="40"/>
</div>
Now I want to change each input whose size is '100' to a textarea which has the same style as the input.
I have tried this:
$("input[size=100]").each(function(){
//how to replace it?
});
Any ideas?
I used this solution found in the answers here:
$("input[size=100]").each(function() {
var style = $(this).attr('style'), textbox = $(document.createElement('textarea')).attr({
id : $(this).id,
name : $(this).name,
value : $(this).val(),
style : $(this).attr("style"),
"class" : $(this).attr("class"),
rows : 6
}).width($(this).width());
$(this).replaceWith(textbox);
});