To use event handlers with dynamically generated elements, you must call .on()
on a shared parent element (does not have to be the immediate parent) and pass the selector of the elements you are interested in. For example:
<div id="parent">
<a class="dynamic-element"></a>
<a class="dynamic-element"></a>
<!-- etc. -->
</div>
<script>
$("#parent").on("click", ".dynamic-element", function() {
// ...
return false;
});
</script>
In the context of your question, instead of:
$("[id^=translateanswer]").on("click", function () {
You might have:
$("#some-parent-element").on("click", "[id^=translateanswer]", function() {