Currently, I am facing an issue while attempting to insert divs into multiple divs that share a common class called ".description"
.
My goal is to assign a unique class to each internal div, but for some reason, this only seems to work for the first div with the specified class.
Here is the code snippet in question:
function addDescriptionFields() {
var i=0;
for(i=1; i<=3; i++) {
$(".description").append("<div></div>");
}
$(".description").each(function() {
$(".description div").eq(0).addClass("game-name");
$(".description div").eq(1).addClass("game-description");
$(".description div").eq(2).addClass("game-popularity");
});
}
As a result, only the first div containing the class ".description"
successfully receives the specified classes for its internal divs, while the others do not.
I am currently seeking assistance to identify and rectify the mistake in my code. Any input would be greatly appreciated.