title: change font color of a row in jquery ajax table
body: <p>I want to change the font color of values in a row based on the condition that applied inside the function. If the TotalStudent is greater than room capacity, the student information gets added to the table with the font color of red. Below is what I've tried. I've used ajax method and within success function I'm generating table to insert values. The condition is running fine.</p>
  
  <p><strong>Create.cshtml</strong></p>
  
  <pre><code>$.ajax({
    type: "POST",
    url: '@Url.Action("AddStudent", "Student")',
    data: model,
    dataType: "json",
    success: function(data) {
      $('#dialog').dialog('close');
      alert(data.countstudent);
      alert(data.roomcapacity);
      //var student = data.countstudent;
      if (data.countstudent &gt; data.roomcapacity) {
        var tblEndrolled = $("#tblEnrolled");
        $.each(data.record, function(index, item) {
          $('.status').css("color", "red");
          var tr = $("&lt;tr&gt;&lt;/tr&gt;");
          tr.html(("&lt;td&gt;" + '&lt;input type="submit" id="' + item.Id + '" value="Remove" class="" /&gt;' + "&lt;/td&gt;") +
                  " " + ("&lt;td class = 'status'&gt;" + item.FirstName + "&lt;/td&gt;") +
                  " " + ("&lt;td&gt;" + item.LastName + "&lt;/td&gt;") +
                  " " + ("&lt;td&gt;" + item.EmailAddress + "&lt;/td&gt;") +
                  " " + ("&lt;td&gt;" + item.Phone + "&lt;/td&gt;"));
          tblEndrolled.append(tr);
        });
      }
  
      &lt;div&gt;
        &lt;strong style = "font-size:20px" &gt; Enrolled Students: &lt; /strong&gt; 
          &lt;table class = "table table-bordered table-responsive table-hover" id="tblEnrolled"&gt;
          &lt;tr&gt;
          &lt;th&gt;Action&lt;/th&gt;
                  @*&lt;th&gt;User Id&lt;/th&gt;
                  *@&lt;th&gt;First Name&lt;/th&gt;
                  &lt;th&gt;Last Name&lt;/th&gt;
                  &lt;th&gt;Email&lt;/th&gt;
                  &lt;th&gt;Phone&lt;/th&gt;
          &lt;/tr&gt;
          &lt;/table&gt; 
          &lt;/div&gt;
  </code></pre>