Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/420.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在jQuery中跨div拆分文本_Javascript_Jquery_Html - Fatal编程技术网

Javascript 在jQuery中跨div拆分文本

Javascript 在jQuery中跨div拆分文本,javascript,jquery,html,Javascript,Jquery,Html,我正在做一个游戏,我需要把一个长文本分成500个单词,然后把它们分成不同的部分。我一直在编写一些我拼凑起来的代码,因为我的代码有点弱。如您所见,代码将文本拆分,并在每个div中创建一个新div,该div具有类“column”,但我希望每个具有类“column”的div都有其文本部分 $(文档).ready(函数(){ var contentBlocks=$('#content').text().replace(/.{500}\S*\.\S+/g,$&').split(/\.\S+@/); v

我正在做一个游戏,我需要把一个长文本分成500个单词,然后把它们分成不同的部分。我一直在编写一些我拼凑起来的代码,因为我的代码有点弱。如您所见,代码将文本拆分,并在每个div中创建一个新div,该div具有类“column”,但我希望每个具有类“column”的div都有其文本部分

$(文档).ready(函数(){
var contentBlocks=$('#content').text().replace(/.{500}\S*\.\S+/g,$&').split(/\.\S+@/);
var contentBlocksLength=contentBlocks.length;
变量$columns=$('.column'),
$data=$columns.first().find('p'),
size=$data.size(),
columnSize=size/$columns.length;
$('#content').html('');
$.each(内容块、函数(索引、值){
$('.column').append($(''+value+((index!=contentblocksllength-1)?:'')+'');
});
});
.column{
边框:5px纯橙;
浮动:左;
宽度:150px;
}
分区:第n个孩子(2){
边框:5px纯红;
}
分区:第n个孩子(3){
边框:5px纯黄色;
}
}

里基·托马斯·庞廷,AO(生于1974年12月19日),绰号“朋特”,是澳大利亚板球运动员,曾于2004年至2011年参加板球测试赛,2002年至2011年参加国际板球一天赛,担任澳大利亚国家板球队队长。他是一名专业的右手击球手、滑倒和近距离接球外野手,偶尔也会打保龄球。他代表塔斯马尼亚猛虎队参加澳大利亚国内板球比赛,代表霍巴特飓风队参加大巴什联盟,并在2008年与加尔各答骑士队一起参加印度超级联赛。他与印度的萨钦·滕杜尔卡和西印度群岛的布莱恩·拉拉一样,被许多人广泛认为是现代最优秀的击球手之一。2006年12月1日,他达到了近50年来测试击球手的最高评分。1992年11月,Ponting在塔斯马尼亚首次登场,当时他只有17岁337天,成为参加谢菲尔德盾队比赛的最年轻的塔斯马尼亚人。然而,他不得不等到1995年才在新西兰与南非的一场四角杯比赛中首次亮相。随后不久,他参加了1995年在珀斯主场对阵斯里兰卡的系列赛的第一场测试,获得96分。在1999年初之前,由于缺乏形式和纪律,他曾几次失去国家队的位置,然后在2002年初成为一日制国际队长,并在2004年初成为测试队长。在参加了超过160次测试和370次ODI后,Ponting是澳大利亚在测试和ODI板球比赛中领先的跑步记分员。他是历史上仅有的四名获得13000次试跑成绩的球员之一(还有萨钦·滕杜卡尔、拉胡尔·德拉维德和雅克·卡利斯)。据统计,他是有史以来最成功的队长之一,从2004年到2010年12月31日,他在77次测试中获得了48次胜利,同时作为一名球员,他也是历史上唯一一位获得100次测试胜利的板球运动员。[1]2012年11月29日,庞廷宣布退出板球测试,前一天他将参加对南非的珀斯测试。这是他第168次也是最后一次参加测试,与史蒂夫·沃保持的澳大利亚纪录持平。[3][4]里基·庞廷于2012年12月3日以51.85的测试击球率退役。[5]他继续在世界各地打板球。2013年2月,他被宣布将担任印度超级联赛孟买印第安队队长。[6]2013年3月,他被宣布为加勒比超级联赛的第一名国际特许球员。[7]当月晚些时候,Ponting透露,这将是他最后一个打板球的赛季,比赛结束时,他将退出所有形式的比赛。[8]在萨里队对阵诺茨队的最后一局一等投球中,他打出了169个不败球,在辉煌的郡队生涯中总共获得了82个一等100分。

烛台公园从1960年到1999年接待了巨人队,从1971年到2013年接待了49人队。
圣

测试圣

您可以改用吗

.column{
栏目:3个;
}
Ricky Thomas Ponting,AO(生于1974年12月19日),绰号Punter,是澳大利亚板球运动员,曾于2004年至2011年参加板球测试赛,2002年至2011年参加国际板球一天赛,担任澳大利亚国家板球队队长。他是一个年轻人
专业右手击球手、滑倒和近距离接球外野手,以及偶尔的投球手。他代表塔斯马尼亚猛虎队参加澳大利亚国内板球比赛,代表霍巴特飓风队参加大巴什联盟比赛,并在印度超级联赛中出场
2008年与加尔各答骑士联盟。他与印度的萨钦·滕杜尔卡和西印度群岛的布莱恩·拉拉一样,被许多人广泛认为是现代最优秀的击球手之一。2006年12月1日,他获得最高评级
在过去50年中由一名测试击球手完成。1992年11月,Ponting在塔斯马尼亚首次登场,当时他只有17岁337天,成为参加谢菲尔德盾队比赛的最年轻的塔斯马尼亚人。然而,他不得不等到
1995年,在新西兰与南非的一场四角杯比赛中,他首次在国际赛场亮相一天。随后不久,他被选为1995年主场系列赛对斯里兰卡的第一场测试
在珀斯,他得了96分。在1999年初之前,由于缺乏形式和纪律,他曾几次失去国家队的位置,然后在2002年初成为一日制国际队长,并在2004年初成为测试队长。之后
Ponting参加了超过160次测试和370次ODI,是澳大利亚在测试和ODI板球比赛中领先的跑步记分员。他是唯一的一个
<div class="hide" id="content">Ricky Thomas Ponting, AO (born 19 December 1974), nicknamed Punter, is an Australian cricketer, and former captain of the Australia national cricket team between 2004 and 2011 in Test cricket and 2002 and 2011 in One Day International cricket. He is a specialist right-handed batsman, slips and close catching fielder, as well as a very occasional bowler. He represents the Tasmanian Tigers in Australian domestic cricket, the Hobart Hurricanes in the Big Bash League, and played in the Indian Premier League with the Kolkata Knight Riders in 2008. He is widely considered by many to be one of the best batsmen of the modern era, along with Sachin Tendulkar of India and Brian Lara of the West Indies. On 1 December 2006, he reached the highest rating achieved by a Test batsman in the last 50 years. Ponting made his first-class debut for Tasmania in November 1992, when just 17 years and 337 days old, becoming the youngest Tasmanian to play in a Sheffield Shield match. However, he had to wait until 1995 before making his One Day International (ODI) debut, during a quadrangular tournament in New Zealand in a match against South Africa. His Test debut followed shortly after, when selected for the first Test of the 1995 home series against Sri Lanka in Perth, in which he scored 96. He lost his place in the national team several times in the period before early-1999, due to lack of form and discipline, before becoming One Day International captain in early-2002 and Test captain in early-2004. After being involved in over 160 Tests and 370 ODIs, Ponting is Australia's leading run-scorer in Test and ODI cricket. He is one of only four players (along with Sachin Tendulkar, Rahul Dravid and Jacques Kallis) in history to have scored 13,000 Test runs. Statistically, he is one of the most successful captains of all time, with 48 victories in 77 Tests between 2004 and 31 December 2010, while as a player he is also the only cricketer in history to be involved in 100 Test victories.[1] On 29 November 2012 Ponting announced his retirement from Test cricket, the day before he would play in the Perth Test against South Africa. This was his 168th and last Test appearance,[2] equalling the Australian record held by Steve Waugh.[3][4] Ricky Ponting retired on 3 December 2012 with a Test batting average of 51.85.[5] He continued to play cricket around the world. In February 2013 it was announced that he would be captaining the Mumbai Indians team in the Indian Premier League.[6] and in March 2013 he was announced as the first international franchise player for the Caribbean Premier League.[7] Later that month it was revealed by Ponting that this would be his last season playing cricket, as at the end of the competition he would be retiring from all forms of the game.[8] In his final first class innings for Surrey against Notts he hit an unbeaten 169 bringing up a total of 82 first class 100s in an illustrious county career.
<p>
Candlestick Park hosted the Giants from 1960 to 1999 and the 49ers from 1971 until 2013.
The San </p>
<p>
testingThe San </p>
</div>

<div class="columns"></div>
.column {
    border: 5px solid orange;
    float: left;
    width: 150px;
}

.hide {
  display: none;
}

div:nth-child(2) {
    border: 5px solid red;
}

div:nth-child(3) {
    border: 5px solid yellow;
}
$(document).ready(function() {

    var contentBlocks = $('#content').text().replace(/.{500}\S*\.\s+/g, '$&@').split(/\.\s+@/);
    var contentBlocksLength = contentBlocks.length;


    var $columns = $('.column'),
        $data = $columns.first().find('p'),
        size = $data.size(),
        columnSize = size / $columns.length;



    $('#content').html('');




$.each(contentBlocks, function( index, value ) {
    $('.columns').append($('<div class="column textBlock">' + value + ((index != contentBlocksLength - 1) ? '.' : '') + '</div>'));
});


});