Js to get table cell Information)

Source: Internet
Author: User

Js to get table cell information
Obtains the content of a cell in a table.
Var tid = listFrame. now. rows [1]. cells [2]. innerHTML;
ListFrame refers to a window or frame.
Now indicates the table id.
Rows [I] refers to a row, such as the property: length
Cells [j] indicates a cell rows [I]. cells [j] indicates column j of row I.
InnerHTML refers to the cell value.

Example: <! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<Meta name = "Generator" CONTENT = "EditPlus">
<Meta name = "Author" CONTENT = "">
<Meta name = "Keywords" CONTENT = "">
<Meta name = "Description" CONTENT = "">
</HEAD>

<BODY onload = "getTableValue ()">
<Script language = "javascript">
Function getTableValue (){
Alert (document. getelementbyid ('table1'). Rows [0]. cells [0]. innerhtml );
// Or
Alert (document. getelementbyid ('table1'). Rows. Item (0). cells. Item (0). innerhtml );
}
</SCRIPT>
<Table id = "Table1">
<Tr>
<TD> 1 </TD>
<TD> 2 </TD>
</Tr>
<Tr>
<TD> 3 </TD>
<TD> 2 </TD>
</Tr>
</Table>
</BODY>
</HTML> Note: To be compatible with IE and FireFox, do not use innerText.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.