Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a particular cell value from HTML table using JavaScript

Tags:

I want to get each cell value from an HTML table using JavaScript when pressing submit button.

How to get HTML table cell values?

like image 515
Saravanan Avatar asked Nov 23 '10 07:11

Saravanan


People also ask

How do I find the value of a cell in a table?

To get the value of the clicked cell, the jQuery solution is to attach a click event to all the table cells and assign the highlight CSS to the clicked cell and obtain its value. Then show this value on the screen by assigning it to the span element.

How can get HTML table cell value in jQuery?

$('#mytable tr'). each(function() { var customerId = $(this). find("td:first"). html(); });

How can I get TD value?

jQuery: code to get TD text value on button click. text() method we get the TD value (table cell value). So our code to get table td text value looks like as written below. $(document). ready(function(){ // code to read selected table row cell data (values).


Video Answer


1 Answers

To get the text from this cell-

<table>     <tr id="somerow">         <td>some text</td>                 </tr> </table> 

You can use this -

var Row = document.getElementById("somerow"); var Cells = Row.getElementsByTagName("td"); alert(Cells[0].innerText); 
like image 198
pavanred Avatar answered Oct 16 '22 11:10

pavanred