且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

foreach 相当于 jquery 中的 php?

更新时间:2022-05-01 22:05:53

$.each 功能类似.

它允许您使用可以访问每个项目的回调函数迭代数组:

It allows you to iterate arrays using a callback function where you have access to each item:

var arr = [ "one", "two", "three", "four", "five" ];


$.each(arr, function(index, value) {
  // work with value
});

知道也许有用,如果你想打破循环,你可以用 return false; 或者如果你只想跳过一次迭代(继续),你 return真;

Maybe is useful to know, if you want to break the loop, you can do it with return false; or if you want to skip only one iteration (continue), you return true;