我可以把它切成两半,我只是不知道如何去确保一半直到下一个关闭块级标签。
假HTML:
<div class="content-item">
<h1>Title</h1>
<p>Pellentesque nec erat diam. Donec condimentum tortor nec tellus gravida uscipit</p>
<h1>Title</h1>
<p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus</p>
</div>
到目前为止的Javascript:
var splitChar = " ";
var wordsSplit = $(".content-item").html().split(splitChar);
var wordsCount = wordsSplit.length;
var half = Math.floor(wordsCount / 2);