jQuery Simple Example
HTML
<script src="//www.addressfinder.co.nz/assets/v2/widget.js"></script>
<div id="content">
</div>
JavaScript
$(document).ready(function() {
var list = ['goal 1', 'goal 2', 'goal 3', 'goal 4', 'goal 5'];
for (var i = 0; i < list.length; i++) {
var text = list[i];
var pEl = $('<p></p>', {
text: text
});
pEl.prop('arrayIndex', i);
pEl.on('click', function(e) {
goToGoal(e, $(this).prop('arrayIndex'));
});
$('#content').append(pEl);
}
});
function goToGoal(e, i) {
alert('go to goal array index = ' + i);
}