如何能跳出jquery的each循环
时间:2009-07-17
来源:互联网
用each循环的时候,我在里面做了一个判断,如果为假,我要跳出each循环,不再继续循环下去了,应该写什么语句呢?
写return不能跳出each循环,break不能用。
写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;}
});
项目上用的
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
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28