Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jQuer中each和forEach的区别: #3

Open
gaowei1012 opened this issue Jun 14, 2017 · 0 comments
Open

jQuer中each和forEach的区别: #3

gaowei1012 opened this issue Jun 14, 2017 · 0 comments

Comments

@gaowei1012
Copy link
Owner

jquery中foreach 语句为数组或对象集合中的每个元素重复一个嵌入语句组。foreach 语句用于循环访问集合以获取所需信息,但不应用于更改集合内容,能够应用的编程语言类别:Java、C# 、PHP、D语言(Phobos库)。

     a.forEach(function() {  
     <span style="white-space:pre">  </span>//body...  
});

each()函数是基本上所有的框架都提供了的一个工具类函数,通过它,你可以遍历对象、数组的属性值并进行处理。jQuery和jQuery对象都实 现了该方法,对于jQuery对象,只是把each方法简单的进行了委托:把jQuery对象作为第一个参数传递给jQuery的each方法.换句话 说:jQuery提供的each方法是对参数一提供的对象的中所有的子元素逐一进行方法调用。而jQuery对象提供的each方法则是对jQuery内 部的子元素进行逐个调用。

  b.each(function(item){  
  <span style="white-space:pre">  </span>//body...  
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant