コードを最適化しようとしていますが、エラーが発生します。これらは正しく実行されます:
Array.prototype.forEach.call( $('ZA1 .stat'), function( td ) {//ExcuteCode}
Array.prototype.forEach.call( $('ZA2 .stat'), function( td ) {//ExcuteCode}
Array.prototype.forEach.call( $('ZA19 .stat'), function( td ) {//ExcuteCode}
Array.prototype.forEach.call( $('ZA20 .stat'), function( td ) {//ExcuteCode}
これに凝縮しようとしましたが、エラーが発生しました:
for (var trType in allTr) {
//console.log(trType);
Array.prototype.forEach.call( $( window[trType]+' .stat'), function( td ) {
//Excute Code
}
コンソールで、次のエラーが表示されます。
キャッチされないエラー: 構文エラー、認識されない式: [オブジェクト オブジェクト] .stat
jquery セレクターで window[] を使用できますか?