I loaded some HTML from another page via $.ajax:
<script type="text/javascript">
$(function() {
$.ajax({
url: '/getInfo',
context: $('#contentBox'),
success: function(data) {
$(this).html(data);
}
});
});
$(function() {
$('#clickableElement').click(function() {
alert("I work!");
});
});
</script>
<div id="contentBox"></div>
The code loads this HTML into the div with ID contentBox:
<p id="clickableElement">I'm clickable.</p>
However, when I click on the paragraph loaded, no alert box pops up. I don’t think I am accessing the DOM correctly when it comes to elements loaded via AJAX. How can I fix this?
onversion:ondocs: