我有一个输入,它的类型设置为隐藏,我需要将其类型更改为文本.似乎无法弄清楚这一点,或者是否可以使用jQuery
我有以下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>
Run Code Online (Sandbox Code Playgroud)
现在我想将大小为"100"的每个输入更改为与输入具有相同样式的textarea.
我试过这个:
$("input[size=100]").each(function(){
//how to replace it?
});
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我在这里的答案中使用了这个解决方案:
$("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);
});
Run Code Online (Sandbox Code Playgroud)