コメントを外すと、文字列がbody.children().each(calc_deep(1));
取得TypeError: Object [object Window] has no method 'attr'
されparseInt(deepest.attr('deep'))
ますが、コメントを外すことなく、コンソールで確認できますdeepest.attr('deep')
。それは何ですか?
var deepest;
var calc_deep = function(i)
{
$(this).attr('deep',i);
if(i>parseInt(deepest.attr('deep')))
deepest=this;
$(this).children().each(calc_deep(i+1));
}
var find_deepest = function()
{
body=$('body').children().eq(0);
body.attr('deep',0);
deepest=body;
//body.children().each(calc_deep(1));
}
find_deepest();