JSFiddle - React, Tailwind, and code Playground

by cubicalmonkey

HTML

<table id="ethernetProvisiomTable" class="table table-striped" cellspacing="0" cellpadding="0" border="0"><caption>Ethernet Port Info </caption><thead><tr><th class="header">Port</th><th class="header">Admin Status</th><th class="header">Description</th><th class="header">Duplex</th><th class="header">Speed</th><th class="header headerSortUp">Speed-Set</th><th class="header">Status</th><th class="header">Subscriber ID</th></tr></thead><tbody><tr><td>1 <span class="glyphicon glyphicon-info-sign" onclick="ONT_INTERFACE_DETAILS(this)"></span></td><td style="background-color: rgb(0, 128, 0);"><span class="" style="color: rgb(255, 255, 255);">enabled</span></td><td>HEADEND TEST</td><td style="background-color: rgb(255, 0, 0);"><span class="" style="color: rgb(255, 255, 255);">half</span></td><td>10 Mbps</td><td>auto</td><td style="background-color: rgb(255, 0, 0);"><span class="" style="color: rgb(255, 255, 255);">down</span></td><td>HEADEND TEST</td></tr><tr><td>2 <span class="glyphicon glyphicon-info-sign" onclick="ONT_INTERFACE_DETAILS(this)"></span></td><td style="background-color: rgb(0, 128, 0);"><span class="" style="color: rgb(255, 255, 255);">enabled-no-alarms</span></td><td>N/A</td><td style="background-color: rgb(255, 0, 0);"><span class="" style="color: rgb(255, 255, 255);">half</span></td><td>10 Mbps</td><td>auto</td><td style="background-color: rgb(255, 0, 0);"><span class="" style="color: rgb(255, 255, 255);">down</span></td><td>N/A</td></tr></tbody></table>

JavaScript

var tableRow = $("td").filter(function() {
  return $(this).text() == "Speed-Set	Status";
}).closest("tr");
console.log(tableRow)


var SPEED_NEG_COL = $('#ethernetProvisiomTable tr th').filter(function() {
  return $(this).text() == 'Speed-Set';
}).index();
console.log(SPEED_NEG_COL)

$("#ethernetProvisiomTable tr").each(function() {
  console.log($('#ethernetProvisiomTable td').eq(SPEED_NEG_COL).html())
  $('#ethernetProvisiomTable td').eq(SPEED_NEG_COL).html('new content');
});


$("#ethernetProvisiomTable tr").each(function() {
  $(this).find("th").each(function() {
    if ($(this).text().match(/Speed-Set/ig)) { // INDEX column used for Interface m
      var PORT_COLUMN = this.cellIndex + 1;
      $("#ethernetProvisiomTable td:nth-child(" + PORT_COLUMN + ")").append(' <span >ff</span>');

    }
  });
});