-1
私は以下のような構造を持っています。私がしようとしているのは、ユーザーがdivの1つをクリックし、変数の最初の部分(標準)をインデックスと結びつけて配列を取得する場合ですが、そのようにすることはできません($ .eachの後(...クリックに基づいて配列を取得する方法
<div class="selections">
<div id="select1"></div>
<div id="select2"></div>
<div id="select3"></div>
<div id="select4"></div>
<div id="select5"></div>
</div>
$('.selections div').on('click', function (index) {
var numbered = $(this).index() + 1;
var selectedSelect = $('#select' + numbered);
$.each((standard + numbered), function (index, value) {
if (index == numbered) {
//code
}
})
$('#select' + numbered).addClass("selectionBoxActive");
})
var standard1 = [
{ text: "Expertise 1", abbreviation: "AA" },
{ text: "Expertise 2", abbreviation: "AA" },
{ text: "Expertise 3", abbreviation: "AA" },
{ text: "Expertise 4", abbreviation: "AA" },
{ text: "Expertise 5", abbreviation: "AA" }
];
var standard2 = [
{ text: "Expertise 1", abbreviation: "BB" },
{ text: "Expertise 2", abbreviation: "BB" },
{ text: "Expertise 3", abbreviation: "BB" },
{ text: "Expertise 5", abbreviation: "BB" }
];
var standard3 = [
{ text: "Expertise 2", abbreviation: "CC" },
{ text: "Expertise 3", abbreviation: "CC" },
{ text: "Expertise 4", abbreviation: "CC" },
{ text: "Expertise 5", abbreviation: "CC" }
];
var standard4 = [
{ text: "Expertise 1", abbreviation: "DD" },
{ text: "Expertise 2", abbreviation: "DD" },
{ text: "Expertise 3", abbreviation: "DD" },
{ text: "Expertise 4", abbreviation: "DD" },
{ text: "Expertise 5", abbreviation: "DD" }
];
var standard5 = [
{ text: "Expertise 1", abbreviation: "EE" },
{ text: "Expertise 2", abbreviation: "EE" },
{ text: "Expertise 3", abbreviation: "EE" },
{ text: "Expertise 4", abbreviation: "EE" },
{ text: "Expertise 5", abbreviation: "EE" }
];
ええ、私はそれを行うことができます、私はちょうど興味があった – Keith