2010-12-10 97 views
0

目前,feed xml將返回20個項目(子項),每次我只想在單個頁面中顯示10個項目。 jQuery的.each功能會循環整個文檔嗎?但我想讓它只循環10個項目?我需要使用':eq()'嗎?通過jQuery讀取XML節點的好方法?有限循環!

注意:我需要將此用於移動設備環境。

<channel>​ 
<title>​Property​</title>​ 
<link>​</link>​ 
<lastbuilddate>​Wed, 13 Oct 2010 23:50:51 GMT​</lastbuilddate>​ 
<generator>​FeedCreator 1.8.0-dev ([email protected])​</generator>​ 
<atom:link href=​"sample.com" rel=​"self" type=​"application/​rss+xml">​</atom:link>​ 
<item>​ 
    <title>​sample title​</title>​ 
    <description>​ 
    #cdata-section 
    </description>​ 
    <pubdate>Wed, 08 Dec 2010 23:04:25 GMT</pubdate> 
</item>​ 
<item>... ... </item> 
<item>... ...</item> 
<item>... ... repeat 20 times </item> 
<channel>​ 

回答

1

只要你達到數= 10個破發讓一個計數變量,

做一回假

doing a return循環///它應該打破循環

的jsfiddle這裏的示例

http://jsfiddle.net/SxEVT/

+0

ya它是工作,謝謝:) – arkchong 2010-12-10 06:44:35