I am trying to register click on all <td> elements of my array where the class is editable :
<td class="editable"> Test1 </td>
<td class="editable"> Test2</td>
<td class="editable"> Test3 </td>
<td class="editable"> Test4 </td>
JS
function registerClickOnEditableRow() {
for (var i=0; i<$(".editable").length; i++) {
var currentRow = $(".editable")[i];
$(currentRow).click(function() {
$("#oldValueInput").val($(currentRow).text());
});
}
}
Problem : When in click on a random td element, the value of $(currentRow).text() is always equal to the last element registered.