Yii2:Jquery选择表格单元格的ID不起作用

I am using Yii2 and using this jquery code to access the value of a cell(td) column. I have set the id of the column say 'room_name'

I am using this code which works fine on a form, but in grid-view(table) I am getting a blank alert.

<?php      
$script = <<<EOD
alert ($('#room_name').val());

EOD;
$this->registerJs($script);        
?>

Do I need to do it differently for tables, as the id is getting repeated over multiple rows.

Thanks for a suggestion.

I got it from @anpsmn. Adding for record for help to others.

$('td.room_name').each(function(){
    alert($(this).text());
})