I would separate the initial adding of the buttons and the 'click' action.
for (var i = 0; i < 10; i++) {
array
.push($("<a href=\"#\" data-role=\"button\" data-inline=\"true\">"
+ i + "</a>"));
$("#row").append(array[i]);
array[i].click(function() {
changeval(i);
console.log(i);
});
}
Would be split up to:
for (var i = 0; i < 10; i++) {
array.push("<a href=\"#\" data-role=\"button\" data-inline=\"true\">"
+ i + "</a>");
$("#row").append(array[i]);
};
$('#row').on('click', 'a', function() {
changeVal($(this).text());
console.log($(this).text());
};
Also note that variables and functions within javascript should be written in CamelCaseForBetterReadability. Also note that I got rid of the $() surrounding the array items. Lastly, if you do not want to escape the quotations within your string, you can use a single quotation.