我在 JSFiddle http://jsfiddle.net/uWUBE/上为您创建了一个快速而肮脏的“hack”
希望它对您有所帮助,您可以将其编辑为更具动态性。这是一些代码。它基本上循环遍历单词的数量,然后将其添加到您分配给列的字符串中,我根本不是 Javascript 策划者,所以.. 可能有更好的方法。
`
// Get the text
var txt = $("p").text();
// Split every word
var words = txt.split(" ");
// Count the amount of words
var amount = words.length
// Amount of columns
var columnAmount = 2
// Amount of words in first colum
var firstColumn = Math.floor(amount / columnAmount);
// String for first column
var firstColumnTxt = "";
// String for second column
var secondColumnTxt = "";
// loop trough the words and add them to the first column
for (var i = 0; i < firstColumn; i++){
firstColumnTxt = firstColumnTxt + " " + words[i];
}
// loop trough the words and add them to the second column
for (var i = firstColumn; i < amount; i++){
secondColumnTxt = secondColumnTxt + " " + words[i];
}
// Add this to your first column
console.log(firstColumnTxt);
// Add this to your second column
console.log(secondColumnTxt);
`