Find element in previous row and change class
<p>I'm using Datatables with X-editable and have some bootstrap buttons in a table. Basically if the user updates the editable 'Status' column to 'Resolved' I want the button in the 'Not Validated' button in the previous row to turn green. If the status is switched back to any other status it should turn back to red.</p>

<p>I'm using Datatables grouping function to add the 'Not Validated' button.</p>

<p>I have setup a JSFiddle: <a href="http://jsfiddle.net/n74zo0ms/14/" rel="nofollow">http://jsfiddle.net/n74zo0ms/14/</a></p>

<p>JQuery:</p>

<pre><code>//initialize the datatable
$(document).ready(function() {
  var table = $('#dataTables').DataTable({
    "columnDefs": [{
      "visible": false,
      "targets": 0
    }],
    "info": false,
    "searching": false,
    "drawCallback": function(settings) {
      setupXedit();
      var api = this.api();
      var rows = api.rows({
        page: 'current'
      }).nodes();
      var last = null;

      api.column(0, {
        page: 'current'
      }).data().each(function(group, i) {
        if (last !== group) {
          $(rows).eq(i).before(
            '&lt;tr class="group"&gt;&lt;th colspan="2"&gt;&lt;/i&gt;&lt;i class="fa fa-arrow-circle-o-right"&gt;&lt;/i&gt;   Cluster: ' + group + '&lt;/th&gt;&lt;th colspan="1"&gt;&lt;a href="" data-toggle="modal" data-target="" class="btn-sm btn-danger btn-switch" style="display:block;width:99%;text-align:center;"&gt;&lt;i class="fa fa-exclamation-triangle fa-switch"&gt;&lt;/i&gt; Not Validated&lt;/a&gt;&lt;/th&gt;&lt;/tr&gt;'
          );

          last = group;
        }
      });
    }

  });
});

function setupXedit() {
  //initialize the editable column
  $('.status').editable({
    url: '/post',
    pk: 1,
    source: [{
      value: 'New',
      text: 'New'
    }, {
      value: 'In Progress',
      text: 'In Progress'
    }, {
      value: 'Resolved',
      text: 'Resolved'
    }],
    title: 'Example Select',
    validate: function(value) {
      var cell = $(this).parent().parent().find(".btn-switch")
      var cell2 = $(this).parent().parent().find(".fa-switch")
      if (value == 'Resolved') {
        cell.removeClass('btn-danger');
        cell2.removeClass('fa-exclamation-triangle');
        cell.addClass('btn-warning');
        cell2.addClass('fa-thumbs-o-down');
      } else {
        cell.removeClass('btn-warning');
        cell2.removeClass('fa-thumbs-o-down');
        cell.addClass('btn-danger');
        cell2.addClass('fa-exclamation-triangle');
      };

    }
  });
}
</code></pre>