Giving td bgcolor depends on a condition

i'm trying to give a bgcolor inside <td> depends on a condition

$.each(data, function(key, val) {    $('.asoy').append('<tbody><tr><td>' + (angka++) + '</td> <td>' + val.transdate + '</td>' + '<td class="satu">' + val.salespos + '</td><td class="dua">' + val.omset + '</td><td class="dynamic"></td> </tr></tbody>');    if ($(".satu").text() == $(".dua").text()) {      $(".dynamic").css('background-color', 'red');    } else {      $(".dynamic").css('background-color', 'green');    }  }); 

and here is my HTML

<table class="asoy table table-bordered table-hover">   <thead>     <tr>       <td>No</td>       <td>Omset</td>       <td>Sales XML</td>       <td>Tanggal</td>       <td>Status</td>     </tr>   </thead> </table> 

with my script above i only get green i have try to .html() and .val() it's not helping. sorry for my bad english.


Category: jquery Time: 2016-07-29 Views: 0
Tags: jquery

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.211 (s). 12 q(s)