Does not matter where you put your code on server side, since it is rendered in a single http result file. So everything depends on the client side. Try this code:
<html>
<head>
<script src="http://codeorigin.jquery.com/jquery-1.10.2.min.js"></script>
<script>
function nextBenefit() {
alert("function called");
}
$(function() {
$("#footer").append(
$('<a />')
.text("Next")
.attr('href', "javascript:;")
.addClass('button')
.bind('click', nextBenefit))
});
</script>
</head>
<body>
<div id="footer"></div>
</body>