I have a function that is called in document.ready() that creates spans.
function configureContentSelector() {
for (j=0; j<centerContent.length; j++)
{
var content = "<span class='contentSelector' onclick='changeContent(" + j + ")' id='span'" + j + ">" + j + "</span>";
$("#contentSelectorArea").html($("#contentSelectorArea").html() + content);
}
Note the spans are id-ed as span0, span1 etc.
Within a separate function that is called when an event unrelated to the spans is fired I want to manipulate the span classes (addClass() removeClass())
$("#" + "span" + i).removeClass("contentSelector");
$("#" + "span" + i).addClass("contentSelectorSelected");
However, this does not work. I believe this issue is related to the fact that the spans are created dynamically but I do not know how to fix this.
Thanks in advance for any help.