OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

JQuery loop through table get ID and change values in a specific column

  • Thread starter Thread starter Simon
  • Start date Start date
S

Simon

Guest
I have a page with 2-3 tables. In those tables I want to change the text of a specific column located in <thead> and also a value in each <td> line, and I would like to get the id from each line.

What is the fastest way to do this, performance-wise?

HTML​


Table-Layout:

Code:
<table class="ms-viewtable">
   <thead id="xxx">
      <tr class ="ms-viewheadertr">
         <th>
         <th>
   <tbody>
      <tr class="ms-itmHover..." id="2,1,0">
         <td>
         <td>
      <tr class="ms-itmHover..." id="2,2,0">
         <td>
         <td>
</table>

JavaScript​


Script with that I started:

Code:
$('.ms-listviewtable').each(function () {
   var table = $(this);

   $table.find('tr > th').each(function () {
      //Code here
   });

   $table.find('tr > td').each(function () {
      //Code here
   });

How can I get the Id? Is this there a better way to do what I want?

<p>I have a page with 2-3 tables. In those tables I want to change the text of a specific column located in <code><thead></code> and also a value in each <code><td></code> line, and I would like to get the <code>id</code> from each line.</p>

<p>What is the fastest way to do this, performance-wise?</p>

<h2>HTML</h2>

<p><strong>Table-Layout:</strong></p>

<pre><code><table class="ms-viewtable">
<thead id="xxx">
<tr class ="ms-viewheadertr">
<th>
<th>
<tbody>
<tr class="ms-itmHover..." id="2,1,0">
<td>
<td>
<tr class="ms-itmHover..." id="2,2,0">
<td>
<td>
</table>
</code></pre>

<h2>JavaScript</h2>

<p><strong>Script with that I started:</strong></p>

<pre><code>$('.ms-listviewtable').each(function () {
var table = $(this);

$table.find('tr > th').each(function () {
//Code here
});

$table.find('tr > td').each(function () {
//Code here
});
</code></pre>

<p>How can I get the Id? Is this there a better way to do what I want?</p>
 

Latest posts

S
Replies
0
Views
1
Safwan Aipuram
S
Top