我有這樣的代碼創建我如何獲得「j」的功能以外的功能?
<table> ... content ...
</ tables>
...我需要「J」的累計值圈外「FOR」後發現......
var dt = $(".table thead th").length;
for (var i = 0; i < dt; ++i) {
(function (j) {
var dt = $(".table thead th").length;
$(".table thead").each(function() {
var $ths = $(this).find('th');
if ($ths.length != 0 && $ths.eq(j).text() != "Estado" && $ths.eq(j).text() != "ESTADO" && $ths.eq(j).text() != "Acciones" && $ths.eq(j).text() != "ACCIONES") {
j = j + ","; // I need this value, the value to be displayed is something like this: 0,1,2,3 ...
alert(j);
}
});
return j;
})(i);
}
/* I need the value of "j" here, but this does not work */
var variable = j;
alert(variable);
它不應該是'函數J()'? – usernolongerregistered
@Agony不,這是一個匿名函數,它接受一個名爲'j'的單個參數。 –