下面是HTML插入文本區域
<input type="text" id="textbox1" />
<input type="text" id="textbox2" />
<input type="text" id="textbox3" />
<input type="text" id="textbox4" />
<a href="#" id="change">Change</a>
<a href="#" id="change1">Change1</a>
我們下面的代碼
var textbox = $("input[type='text']");
var textarea = $("<textarea id='textarea' rows='10' cols='35'></textarea>");
$("#change").click(function() {
$("input[type='text']").each(function(index) {
$(this).hide();
$(textarea).insertAfter(this);
});
});
$("#change1").click(function() {
$('textarea').remove();
$("input[type='text']").show();
});
所以有什麼問題? **在html中的任何元素的'id'必須是唯一的** –
希望你期待** ['this'](https://jsfiddle.net/Guruprasad_Rao/6u9vhp78/)** –