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

jqueryでのループ処理 #60

Open
kzytateishi opened this issue Jun 29, 2013 · 2 comments
Open

jqueryでのループ処理 #60

kzytateishi opened this issue Jun 29, 2013 · 2 comments

Comments

@kzytateishi
Copy link
Contributor

jqueryでのループ処理

  $("ul li").each ->
    console.log this

  for li in $("ul li")
    console.log li

どちらを使いますか?

@s-inagawa
Copy link

var li, _i, _len, _ref;

$("ul li").each(function() {
return console.log(this);
});

_ref = $("ul li");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
li = _ref[_i];
console.log(li);
}

@sakamoto-rh
Copy link

each
上が分かりやすい。
見慣れている(rubyでも使うので。)
thisが変わってしまう。

for in
bind出来る。

上記ケースバイケース
each
 elementの操作を行う場合は適している。
for in
element以外の操作を行う場合は適している。
-> 逆引きするなど。

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

3 participants