Some code of mine uses jquery to create elements <a> with a function given for click behavior:
$(alternatives).each(function (idx, elt) {
var element = $('<span class="label label-success">');
var link = $('<a class="prop' + idx + '" title="' + elt + '">' + elt + '</a>');
link.click(switchLabel);
element.append(link);
list.append(element);
});
The idea here is to catch the click event on the <a class="prop1-0" title="myTitle">my link</a> to change the text in a <span id="corr1-0">my old text</span>. The link between both element is made by the class suffix, f.i. 1-0.
I have several pairs <a>/<span>, I checked every id.
Some links work, but some do not: no error in console, nothing to trace with firebug...
The function binded is :
function switchLabel(e) {
$('#corr'+ e.target.className.substr(4)).text($(e.target).attr('title'));
}
Do you have some tips to help me track this unwanted behavior? May I make a mistake in the implementation?
Regards
indexandidx, is that right?