DEV Community

Ganesh Dhumal
Ganesh Dhumal

Posted on

Answer: How to blink table row based on condition using jquery or php?

Your logic works, you just need to add the blink class to the parent tr of each matching td, which can be achieved using .closest() and addClass():

$(document).ready(function() {
  var empName = 'abc';

  $('#tb_id td.grn').each(function() {
    if ($(this).text() == empName) {
      $(this).css('background-color', '#080').closest('tr').addClass('blink');
    }
  });

Top comments (0)