使用JavaScript从HTML表格获取特定的单元格值 [英] Get a particular cell value from HTML table using JavaScript

查看:293
本文介绍了使用JavaScript从HTML表格获取特定的单元格值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何获取HTML表格单元格值?

解决方案

从这个单元格获取文本 -

 <表> 
< tr id =somerow>
< td>一些文字< / td>
< / tr>
< / table>

您可以使用这个 -

  var Row = document.getElementById(somerow); 
var Cells = Row.getElementsByTagName(td);
alert(Cells [0] .innerText);


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

How to get HTML table cell values?

解决方案

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);

这篇关于使用JavaScript从HTML表格获取特定的单元格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆