1

我已经完成了http://jsfiddle.net/cC8fT/558/并且看不到出了什么问题

<ul><li></li></ul>从维基百科抓取了大量内容。我想我至少会尝试使用列出所有<li>标签的内容

$('ul li').each(function(i) {
    return $(this).text();
});

在下面的数据集上(实际上是这个数据集http://en.wikipedia.org/wiki/Reading_and_Leeds_Festivals_line-ups但我正在尝试使用较小的数据集)

<table class="wikitable plainrowheaders" style="text-align:center;" border="1">
<tr>
<td>Reading Friday</td>
<td>Reading Saturday</td>
<td>Reading Sunday</td>
</tr>
<tr>
<td>Leeds Saturday</td>
<td>Leeds Sunday</td>
<td>Leeds Friday</td>
</tr>
<tr>
<td>
<ul>
<li><a href="/wiki/Green_Day" title="Green Day">Green Day</a></li>
<li><a href="/wiki/System_of_a_Down" title="System of a Down">System of a Down</a></li>
<li><a href="/wiki/Deftones" title="Deftones">Deftones</a></li>
<li><a href="/wiki/Frank_Turner" title="Frank Turner">Frank Turner</a></li>
<li><a href="/wiki/Bring_Me_the_Horizon" title="Bring Me the Horizon">Bring Me the Horizon</a></li>
<li><a href="/wiki/New_Found_Glory" title="New Found Glory">New Found Glory</a></li>
<li><a href="/wiki/Skindred" title="Skindred">Skindred</a></li>
<li><a href="/wiki/While_She_Sleeps" title="While She Sleeps">While She Sleeps</a></li>
</ul>
</td>
<td>
<ul>
<li><a href="/wiki/Eminem" title="Eminem">Eminem</a></li>
<li><a href="/wiki/Chase_%26_Status" title="Chase &amp; Status">Chase &amp; Status</a></li>
<li><a href="/wiki/Foals" title="Foals">Foals</a></li>
<li><a href="/wiki/White_Lies_(band)" title="White Lies (band)">White Lies</a></li>
<li><a href="/wiki/Twin_Atlantic" title="Twin Atlantic">Twin Atlantic</a></li>
<li><a href="/wiki/EarlWolf" title="EarlWolf" class="mw-redirect">EarlWolf</a></li>
<li><a href="/wiki/The_Blackout_(band)" title="The Blackout (band)">The Blackout</a></li>
<li><a href="/wiki/Lower_Than_Atlantis" title="Lower Than Atlantis">Lower Than Atlantis</a></li>
<li><a href="/wiki/Mallory_Knox_(band)" title="Mallory Knox (band)">Mallory Knox</a></li>
</ul>
</td>
<td>
<ul>
<li><a href="/wiki/Biffy_Clyro" title="Biffy Clyro">Biffy Clyro</a></li>
<li><a href="/wiki/Nine_Inch_Nails" title="Nine Inch Nails">Nine Inch Nails</a></li>
<li><a href="/wiki/Fall_Out_Boy" title="Fall Out Boy">Fall Out Boy</a></li>
<li><a href="/wiki/The_Lumineers" title="The Lumineers">The Lumineers</a></li>
<li><a href="/wiki/Editors_(band)" title="Editors (band)">Editors</a></li>
<li><a href="/wiki/Don_Broco" title="Don Broco">Don Broco</a></li>
<li><a href="/wiki/Hadouken!" title="Hadouken!">Hadouken!</a></li>
<li><a href="/wiki/We_Are_the_In_Crowd" title="We Are the In Crowd">We Are the In Crowd</a></li>
<li><a href="/wiki/Bury_Tomorrow" title="Bury Tomorrow">Bury Tomorrow</a></li>
</ul>
</td>
</tr>
</table>

然而,我得到的只是数据集而不是内容。第二阶段是删除所有 URL 并获取文本

4

1 回答 1

2

使用map代替each

var texts = $('ul li').map(function() {
    return $(this).text();
}).get();
于 2013-09-17T14:33:04.730 回答