You can simplify your code and make use of jQuery instead of querySelectorAll
:
$(function change_cell_content() {
$("td").on("click", function () {
var cell_id_ref = $(this).attr('cellID');
var $table = $(this).closest('table');
var newValue;
var currentValue = $(this).html();
alert(currentValue);
var changeValue = prompt("Enter a new value. (Current " + currentValue + ")");
if (changeValue !== null) {
$table.find('[cellID="' + cell_id_ref + '"]').text(changeValue);
}
});
});
You problem was in this line:
document.querySelector('[cellID="' + $cell_id_ref + '"]').innerHTML = ...
You should select a cell in current table, however above code always selects the first cell from the first table.