将TextArea和Colspan添加到动态创建的表行

时间:2012-03-24 11:32:19

标签: javascript html-table textarea

我正在关注硬编码表数据

 <td colspan="4">
   <textarea rows="4" cols="40"></textarea>
 </td>

但我想用Javascript或jQuery做这件事,任何人都可以告诉我如何做到这一点。

1 个答案:

答案 0 :(得分:1)

做吧。

var td = document.createElement('td');

td.setAttribute('colspan', '4');

var textarea = document.createElement('textarea');

textarea.setAttribute('rows', '4');
textarea.setAttribute('cols', '40');

td.appendChild(textarea);
相关问题