我在.each方法里调用一个自定义函数,红色字体部分是原来自定义函数李的内容。
我把它移到.each里也是不执行的。
- JScript code
$('table.timetable th').each(function(index){ var text= $(this).text(); [color=#FF0000]$(nday).each(function(i){ //alert('....') 加断点才会运行 if(day[text]==nday[i]){ //day,nday是数组 $('table.timetable').find('td') .filter(':nth-child('+(index+1)+')') .addClass('cannotchoose'); } }); [/color] });
请各位帮忙解决一下,我都忙了一天了
------解决方案--------------------
$('table.timetable th').each(function(index){
var text= $(this).text();
$(nday).each(function(i){
//alert('....') 加断点才会运行
if(day[text]==nday[i]){ //day在这里能得到么????
$('table.timetable').find('td')
.filter(':nth-child('+(index+1)+')')
.addClass('cannotchoose');
}
});
});
------解决方案--------------------
LZ提供的资料太少,无从准确判断问题所在。
------解决方案--------------------
一般情况下不会出现这个情况,但是day[text]==nday[i]可能是你没有定义,第一次没有循环
------解决方案--------------------
是有这个问题,我也经常碰到,通常,用下面的方法来遍历
$.each(obj,function(index,strResult)
{
//index是索引,strResult是值
});
------解决方案--------------------
把你的ALERT换成一个需要一定时间执行的方法试试。
比如
for(i=0;i<999999;i++){}