javascript - 在动态生成的表中插入换行符

标签 javascript jquery

我有由 salesfoce 中的 Apex 代码呈现的表格。

<div id="wrap" style=""><fieldset style="border: none;"><table role="presentation" style="">
	<tbody><tr>
    <td>
<input type="radio"value="Casual"><label for="j_id0:j_id2:j_id4:j_id112:0"> CASUAL</label></td>
<td>
<input type="radio" value="BUSINESS CASUAL"><label for="j_id0:j_id2:j_id4:j_id112:1"> BUSINESS CASUAL</label></td>
<td>
<input type="radio" value="Semi-Formal"><label for="j_id0:j_id2:j_id4:j_id112:2"> SEMI-FORMAL</label></td>
<td>
<input type="radio" value="Formal"><label for="j_id0:j_id2:j_id4:j_id112:3"> FORMAL</label></td>
<td>
<input type="radio" value="Costume"><label for="j_id0:j_id2:j_id4:j_id112:4"> COSTUME</label></td>
<td>
<input type="radio" value="Other"><label for="j_id0:j_id2:j_id4:j_id112:5"> OTHER</label></td>
	</tr>
</tbody></table></fieldset>
            </div>

我需要打破第三个标签之后的行。这意味着一行中有三个输入/标签。 我可以使用 jQuery。我已经尝试过诸如注入(inject)关闭</tr>之类的一切通过innerHTML等第三次输入后的标签。但似乎没有任何作用。

最佳答案

尝试稍微操作一下 DOM,

$('<tr>').append($('tr td:gt(2)')).appendTo('tbody');

DEMO

关于javascript - 在动态生成的表中插入换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27525357/

相关文章:

jquery - 需要有关 float (粘性)元素的帮助

javascript - 限制全日历中每天创建的事件数

jquery - jQuery 1.5 的 jqXHR 的原因/主要好处是什么?

javascript - react 和导入类

javascript - 如何在 npm 包中添加文件夹作为条目?

javascript - 在 jQuery 中将一列的内容复制到另一列

javascript - 在 css :hover doesn't work anymore 中拖动变换后的 Interact.js

javascript - 文本未标记

javascript - 在 AJAX 调用中通过查询字符串发送时丢失 unicode 字符

javascript - 从 html javascript 调用时,Adobe AIR history.back() 不起作用