您将表格数据放入两个单独的分隔符中。无论您如何设计分隔线,在进行文本选择时,段落永远不会并排。如果您无法更改标记,您可以做的一件事是将其转换为表格:
/* Count the total number of children within the first divider.
* This assumes both will always be equal. */
var total = $('div:first-child').children().length,
/* Create the table. */
table = $('<table><tbody></tbody></table>');
/* Loop from 0 to total. */
for(i=0;i<total;i++)
{
/* Create the table row. */
var tr = $('<tr></tr>'),
/* Index will be i + 1, store this as new variable. */
j = i + 1;
/* Loop through each matching nth-child. */
$('div p:nth-child(' + j + ')').each(function() {
/* Create the table cell. */
var td = $('<td></td>');
/* Set the cell's text to the paragraph's text. */
td.text($(this).text());
/* Append cell to row. */
td.appendTo(tr);
})
/* Append row to table's tbody. */
tr.appendTo($('tbody', table));
}
/* Append table to body. */
table.appendTo('body');
/* Remove dividers. */
$('div').remove();
JSFiddle 示例。