如何检查每个函数是否都通过了整个数组 (javascript/jquery)?
How can I check if the function each passsed through the entire array (javascript/jquery)?
例如此代码:
$("div.content").each(function() {
// content
});
我如何告诉浏览器在阅读完这个函数后开始阅读代码的其他部分?
我试过类似的方法,但没有用:
var string = $("div.content").each(function() {
// content
});
if (string) { // content }
在每个函数方法中使用两个参数。
检查下面的代码
$("div.content").each(function(element, i) {
console.log(element, i);
// or add your custom logic on each element
});
如果你想检查数组当前元素的索引,你需要做的是添加另一个参数,如下所示。第二个参数将是数组中元素的索引。
$("div.content").each(function(elem, i) {
//content
});
例如此代码:
$("div.content").each(function() {
// content
});
我如何告诉浏览器在阅读完这个函数后开始阅读代码的其他部分?
我试过类似的方法,但没有用:
var string = $("div.content").each(function() {
// content
});
if (string) { // content }
在每个函数方法中使用两个参数。 检查下面的代码
$("div.content").each(function(element, i) {
console.log(element, i);
// or add your custom logic on each element
});
如果你想检查数组当前元素的索引,你需要做的是添加另一个参数,如下所示。第二个参数将是数组中元素的索引。
$("div.content").each(function(elem, i) {
//content
});