
Table Navigation in JS
Table navigation in JavaScript allows you to move through table elements (<table>, <tr>, <td>, etc.) dynamically. You can navigate rows, cells, and even specific elements inside a table.
Navigating Table Elements
The key DOM properties for table navigation are:
Example Table Structure
<table id="myTable" border="1">
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
</tr>
</table>
Navigating Table Rows
Here's an example of how to navigate through table rows:
let table = document.getElementById("myTable");
let rows = table.rows;
for (let row of rows) {
console.log(row); // Logs each
}
Get a Specific Row by Index
let table = document.getElementById("myTable");
let rows = table.rows;
for (let row of rows) {
console.log(row); // Logs each
}
Navigating Table Cells
Here's an example of how to navigate through table cells:
let firstRow = table.rows[0];
let cells = firstRow.cells;
for (let cell of cells) {
console.log(cell.innerText); // Logs each cell's text
}
Get a Specific Row by Index
let specificCell = table.rows[1].cells[1]; // Second row, second cell
console.log(specificCell.innerText);
Introduction
Control Flow and Decision Making
Strings and Array
JavaScript in Browser
Navigation in JS
Browser Events in JS
Callbacks, Promises, and Async/Await
-
Introduction and error handling of Callbacks in
js
-
Callback
Hell and Pyramid of Doom in js
-
Introduction to Promises in js
-
Promise
Chaining in js
-
Async &
Await in js
-
Movie
Search App using js(Project-V)
-
Book
Finder App using js(Project-VI)
-
Fetch
API and it's types
-
Sending
Post Request with Fetch API
-
Cookies
in JS
-
Local
Storage and Session Storage in JS
-
Quiz App
in JS
OOP's in JS
-
Introduction to OOP's in JS
-
Classes
and Objects in JS
-
Constructors in JS
-
Inheritance in JS
-
Method
overriding and Constructor overriding in JS
-
Static
Method(Public and Private Property) in JS
-
Getters,
Setters and instanceOf in JS
-
Password
generator using JavaScript
-
IIFE,
Destructuring and Spread Operator in JS
π’Important Noteπ’
How did you feel about this post?
π
π
π
π
π‘
Was this helpful?
π
π