0

我有文件,例如:

This is the first line
<br> 
This is the second line 
<br>
This is the third line

现在我想删除<br>并格式化文本,如下所示,

    <DIV ID=PAGINATION-CONTENT>
        This is the first line
    </DIV>
    <DIV ID=PAGINATION-CONTENT>
        This is the second line 
    </DIV>
    <DIV ID=PAGINATION-CONTENT>
       This is the third line
    </DIV>

使用 jquery 怎么可能?

4

2 回答 2

1

像这样的东西?我使用classes的ID必须是唯一的!

<p>
  This is the first line
  <br>
  This is the second line
  <br>
  This is the third line
</p>

var lines = $('p').html().split('<br>')
var divs = '';
$.each(lines, function(i, line) {
    divs += '<div class="PAGINATION-CONTENT">'+line+'</div>';
})

$('p').html(divs)  

演示

于 2012-08-07T04:10:59.357 回答
0

您可能正在寻找page-break-beforepage-break-aftercss 规则。

假设您正在谈论实际的分页符(即打印时)。如果不是,那么您的问题非常不清楚。

于 2012-08-07T04:05:24.323 回答