0

I have set markup HTML ON in my pl/sql script. I'm running a select query whose output by default as a table I'm writing to a html file.

I want to highlight a few rows in that table based on the value of a column. For that I'm trying to set a CSS class for those rows.

From CSS, I can only access table's <th> and <td> in general. Kindly suggest how this can be done.

William Robertson
  • 15,273
  • 4
  • 38
  • 44
user3387219
  • 139
  • 1
  • 1
  • 7
  • I'm not familiar with it at all, but from quick reading in the [docs](https://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_seven.htm#i1043391), it seems that it impossible. BUT, you can highlight **part** of the row. I mean, you can set the html **inside** the cell, so, I guess, you can add `style` attribute to each row **content**. – Mosh Feu Aug 15 '17 at 13:51
  • td:nth-child(n) { /* your stuff here */ } https://stackoverflow.com/questions/15675097/style-the-first-td-column-of-a-table-differently – Andrey Khmelev Aug 15 '17 at 18:17

1 Answers1

0

$(function() {
  var val = ['X', 'Z'];
  for (var i = 0; i < val.length; i++) {
    $('table tr td:contains(' + val[i] + ')').each(function() {
      $(this).closest('tr').addClass('highlight');
    });
  }
});
.highlight td {
  border: 1px solid blue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
  <tr>
    <td>A</td>
    <td>B</td>
  </tr>
  <tr>
    <td>A</td>
    <td>X</td>
  </tr>
  <tr>
    <td>A</td>
    <td>V</td>
  </tr>
  <tr>
    <td>X</td>
    <td>B</td>
  </tr>
  <tr>
    <td>Z</td>
    <td>B</td>
  </tr>
</table>

If you have a specific range of values, so as to get tr highlighted, You can use something like this. I don't know how to exactly style the 'tr' to make it highlighted.

gjijo
  • 1,206
  • 12
  • 15