2010-04-13 57 views

回答

3

东西,你已经接近:

$$('input.required').each(function(i){ 
    console.log($F(i)); 
}); 

与类的required所有输入将通过迭代,并显示给Firefox的控制台自己的价值。如果您不使用Firefox,只需将console.log更改为alert即可查看结果。

+0

约翰,感谢您的回复,我几乎没有,2件更多的事情,如果你会这么好心;在代码中: $$('input.required')。each(function(i){0,1,2} ){ alert(“Must Enter”+ i.name); i.focus(); return; } }); 1)是空的()足以检查空字符串和空白字符串吗? 2)返回不打破循环,我怎么能离开“每个”循环? – xain 2010-04-13 19:07:09

+0

我很确定空()将为空。尝试'抛出$ break'来突破each()循环。 – 2010-04-13 19:21:25

+0

工作得很好,谢谢! – xain 2010-04-13 20:20:41

0

它适用于我。

示例代码:

document.observe("dom:loaded", function() { 
    var maxHeight = 0; 

    $$('.product-name').each(function(i){ 

     var eleHeight = i.getHeight(); 

     if (eleHeight > maxHeight){ 
      maxHeight = eleHeight; 
     } 
    }); 

    $$('.product-name').each(function(i){ 
     i.setStyle({ 
      height: maxHeight+'px' 
     }); 
    }); 
});