Skip to content
Advertisement

is there a way to get the value from the first cell in html table row using javascript only?

I’m trying to figure out how to get the value from the first column of selected row inside the HTML table i’m selecting the row using button created using this js code :

JavaScript

the table is created from code behind using stringbuilder what I tried is this:

JavaScript

then i want to get the selected row id , what i have tried :

JavaScript

Advertisement

Answer

You can use querySelector to get the first element. If it has more than one of similar elements, it always gets the first one.

Your cell does not have value either. You should use innerText instead.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement