https://codepen.io/jh-ko/pen/OBrMOO
var table = [1, "red", 3,
4, "blue", 6];
for (var i = 0; i < table.length; i += 3) {
var x = table[i];
var y = table[i+1];
$(".Ali:nth-child(" + (x++) + ")").click(function() {
$("div .me:nth-child(" + (x++) + ")").css("color", y);
});
}
--There is an example (codepen) on the top.--
I have 2 classes .Ali and .me
First of all, i want to have the same nth-child value of both classes. For example, when i click nth-child(1) of Ali class , i want to get the color red in nth-child(1) of me class.
but i get a blue in this code, ...
When i code it just with number directly, it works well.
".Ali:nth-child(4)"
"div .me:nth-child(4)"
My Goal: When i click a number (for example 3) in Group A, i want to have the color on the same number in Group B..