Use this .on() form (in the comments below).
$(document).on("click", '[id^=updateVersionItem]', function(event, ui) { console.log("updateVersion, selected = " + $(this).attr('id')); })
Example: http://jsfiddle.net/saluce/YaAEJ/
Otherwise, whenever you dynamically add new elements, you need to attach the click event to these elements.
Assuming the following code:
function doThisOnClick(event, ui) { console.log("updateVersion, selected = " + $(this).attr('id')); } $('[id^=updateVersionItem]').on("click", doThisOnClick);
You can either untie the handler or bind it to all the relevant elements:
$('[id^=updateVersionItem]').off("click", doThisOnClick); $('[id^=updateVersionItem]').on("click", doThisOnClick);
Or simply dynamically add it to new elements after adding it:
$("#updateVersionsList").append('<li><a id="updateVersionItem-' + (i+3) + '">' + versions[i] + '</a></li>').on("click", doThisOnClick);
source share