+ -
当前位置:首页 → 问答吧 → 如何能跳出jquery的each循环

如何能跳出jquery的each循环

时间:2009-07-17

来源:互联网

用each循环的时候,我在里面做了一个判断,如果为假,我要跳出each循环,不再继续循环下去了,应该写什么语句呢?

写return不能跳出each循环,break不能用。
[ 此帖被signs在2009-08-20 15:05重新编辑 ]

作者: signs   发布时间: 2009-07-17

var hot_i = 1;
var divstring = new Array();
divstring.push('<div class="ws_TitleBlk02"><h3><span>视频</span></h3></div>');

$("item",data).each(function(i, domEle){                
    divstring.push('<div class="ws_imgTxt02">\r\n<div class="wiT02_i"><a href="ss_play.asp?typeid=&blogid=');                            
    divstring.push($(domEle).children("id").text() + '"><img src="pic/');
    divstring.push($(domEle).children("pic").text() + '" alt="');
    divstring.push($(domEle).children("name").text() +'" border="0" width="67" height="50" title="');    
    divstring.push($(domEle).children("name").text() + '"></div><div class="wiT02_t"><h4><a href="zp_display.asp?typeid=&blogid=');
    divstring.push($(domEle).children("id").text()  + '" title="');                                                
    divstring.push($(domEle).children("name").text() + '">');
    divstring.push($(domEle).children("name").text() + '</a></h4><p>');
    divstring.push($(domEle).children("description").text().substr(0,20) + '</p></div></div>\r\n<div class="clearit"></div>\r\n<div class="list_bot"></div>\r\n');                                            


if ( ++hot_i > 6){return false;}
});

项目上用的

作者: jmbajh   发布时间: 2009-07-17

return false;

作者: keakon   发布时间: 2009-07-17

可以跳出,多谢啊两位,加油

作者: signs   发布时间: 2009-07-18

相关阅读 更多