Problem with adding id column in js

Hi guys! I have a problem to add id at grid columns. I want to use js to show in a field form the value of the columns. This is my code:

$js = <<< JS
$("#foo").click(function replaceText() {
var x=document.getElementById(‘foo’).innerHTML;
//Correct here



The problem is that it is successfull only with the first column, not for the others. Some help? Thank you very much!!!