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,
- HTML5 HELLO WORLD Example
- All directional arrows codes for HTML
- Adding Sub Headings to Bootstrap Header tags
- Create HTML button that looks like a href hyperlink
- 70+ HTTP Error Codes CheatSheet
- Comprehensive 256 Ascii code table with Html Hex IBM Microsoft Key
- How to set background color in HTML page?
- Obsolete marquee element alternatives html5
- Base 64 Index, Character and Binary Table
- Get HTML table td, tr or th inner content value with id or name attribute
- Align html element at the center of page vertically and horizontally
- How to add multiple spaces between html page text
- The author stylesheet specified in tag script is too long - document contains 21759 bytes whereas the limit is 10000 bytes
- How to pretty print HTML using Java Code
- W3 HTML validator warning Unable to Determine Parse Mode
- Hyperlink in html (anchor tag) without a underline
- reCaptcha Verification expired. Check the checkbox again
- Auto Refresh Webpage after every x Second or Minute using Meta Tag?
- Chessboard with pieces using pure HTML and CSS
- Default speed of Marquee tag : SCROLLAMOUNT
- Fibonacci series from 1 to 500 table
- 9 Border to DIV Element in HTML Examples
- How to remove old 404 pages ulrs from Google crawler
- Simple Crossword Puzzle example using Pure HTML, CSS and JavaScript
- How to make a div tag clickable
More Posts:
- How to adjust MacBook Desktop icons size - MacOS
- How to rename a Pandas DataFrame Column Names - Python
- Fix SharePoint PowerShell error - The term Get-SPweb is not recognized as the name of a cmdlet function script file or operable program - SharePoint
- [macOS] How to search or view previous terminal command history - MacOS
- How to format LocalDate in Java using DateTimeFormatter - Java
- Eclipse Error : The Eclipse executable launcher was unable to locate its companion shared library. - Eclipse
- Json Serialization and Deserialization using Java Jackson - Java
- Running Android Lint has encountered a problem NullPointerException Error - Android