I cannot bind events to the list generated by jQuery. I examined some similar problems, but havent found any solution.
This is the code that my list generates:
var list = '<ul>'; for (var i = 0; i < data.length; i++) { list += '<li id="' + data[i].id + '"><span class="btnRemoveItem" title="Remove item from list"></span>' + data[i].name + '</li>'; } list += '</ul>'; jQuery("#spanContainer").html(list);
This creates my list. It works great. But I can not manipulate the list through jQuery. Some studies point me towards linking events to my list. How should I do it? I looked through several posts having the same problem, but did not find anything that resolved my problem.
I am using jQuery 1.2.6 and cannot use v.1.3 (which has a .live function).
Resources: docs.jquery.com/Events/bind
Edit: I tried this, but it does not work.
jQuery ("# ββ7276"). bind ("click", function () {alert ('test');})
This html output:
<span id="itemList"> <ul> <li id="listItem_7276"><span title="Remove item from list" class="btnRemoveItem" id="7276"/>Main item</li> <li id="listItem_7281"><span title="Remove item from list" class="btnRemoveItem" id="7281"/>Test item 4</li> </ul> </span>
source share