【发布时间】:2013-06-13 09:08:37
【问题描述】:
我有以下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>
现在我想将每个大小为“100”的输入更改为与输入具有相同样式的文本区域。
我试过这个:
$("input[size=100]").each(function(){
//how to replace it?
});
有什么想法吗?
我使用了答案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);
});
【问题讨论】:
-
这对 Google 来说是微不足道的。
-
我试过了,还是不行。顺便说一句,我认为我的帖子不值得投反对票。
-
谷歌不工作?它对我有用。我得到的第一个打击是例如jQuery change hidden input type to textarea - 如果您对 that 有特定问题,您应该将它们添加到问题中
-
google.com.hk/… 。这就是我得到的。
-
另外,我发现这个
$('code').contents().unwrap().wrap('<pre/>');但它不适用于输入元素。
标签: jquery