Here is how we can get the value from a table element like td, th or tr having id or name attribute,
<table>
<tr>
<td id="td_tag">Test</td>
</tr>
</table>
For the above td tag we can get the inner content by,
document.getElementById("td_tag").innerText;
document.getElementById("td_tag").textContent;
Example:
<html>
<head>
</head>
<body>
<table>
<tr>
<td onClick="getTableInnerConent();" id="td_tag">This is some text!</td>
</tr>
</table>
</body>
<script>
function getTableInnerConent() {
alert(document.getElementById("td_tag").innerText);
alert(document.getElementById("td_tag").textContent);
}
</script>
</html>
More Posts related to Html,
- How to remove old 404 pages ulrs from Google crawler
- W3 HTML validator warning Unable to Determine Parse Mode
- Comprehensive 256 Ascii code table with Html Hex IBM Microsoft Key
- Align html element at the center of page vertically and horizontally
- HTML Images - Attributes and Formats
- 9 Border to DIV Element in HTML Examples
- Create HTML button that looks like a href hyperlink
- What is the doctype for HTML5?
- Simple Crossword Puzzle example using Pure HTML, CSS and JavaScript
- How to make a div tag clickable
- The author stylesheet specified in tag script is too long - document contains 21759 bytes whereas the limit is 10000 bytes
- W3 : character data is not allowed here html validation error
- How to set background color in HTML page?
- Auto Refresh Webpage after every x Second or Minute using Meta Tag?
- Default speed of Marquee tag : SCROLLAMOUNT
- Get HTML table td, tr or th inner content value with id or name attribute
- How to add multiple spaces between html page text
- Chessboard with pieces using pure HTML and CSS
- How to turn off autocomplete in input fields in HTML Form
- remove div vertical scroll
- Fibonacci series from 1 to 500 table
- Remove Html head and body tags from ckeditor source
- reCaptcha Verification expired. Check the checkbox again
- HTML5 CSS3 Color Codes List
- All directional arrows codes for HTML
More Posts:
- Division between two numbers - C-Program
- How to install Microsoft Teams on Mac using Terminal (Silently) - Teams
- How to lock Notepad++ tabs? - NotepadPlusPlus
- Add or remove users from sudo group - Ubuntu - Ubuntu
- Shortcut: How to delete a complete line in Nano Editor - Linux
- Java JDBC Connection with Database using SSL (https) URL - Java
- Json Serialization and Deserialization using Java Jackson - Java
- [Java Threads] Should we extend Thread Class or implement Runnable interface - Java