So I am injecting html
via an AJAX request:
Ajax Response
HTML from AJAX request
Try to use jQuery.on
function: http://api.jquery.com/on/
$(document).on('click', '#my-element', function () { ... });
Then it will work even with dinamically added elements.
Add your event after injecting html via an AJAX request has been completed
or
you can use on
method
see this example also
Event binding on dynamically created elements?
Use the on
method to make it live.
$(function(){
$("#my-element").on("click",function() {
alert("hit");
});
});
Do the binding in the success callback of your ajax call, after you ahve inserted the html into the DOM.