I've encountered an issue with a list that I am trying to modify its content when hovering over them. Despite using the id as a selector for triggering the hover function, all list items change color instead of just the intended one. The challenge lies in the fact that the ids are dynamically generated, making it impossible to target individual elements. Below is a snippet of the pertinent jQuery code:
for (var i=0;i < count; i++)
{
if (i == 4) {break;}
var elemId = resultsTemp[i].split('.')[0];
var elemName = resultsTemp[i].split('.')[1];
addToList += '<li id="'+elemId+'" class= "profResultsName">'+elemName+'</li>';
}
$("#professorDropDown").append(addToList);
Additionally, here's another snippet:
$(".profResultsName").hover(function()
{
$(this).css("color","white");
},
function ()
{
$(this).css("color","black");
});
Finally, below is the relevant HTML structure:
<ul id="professorDropDown" class="addContainer"></ul>