how to compare the current line and the one that appears in its place when ajax request. In particular, I want to implement such a mechanism, which will update the cryptocurrency rates and accompany it with colors. So the question is how do I compare these values
$("document").ready(function() { function get() { $.ajax({ url: 'pars.php', type: 'POST', success: function(data) { var obj = jQuery.parseJSON(data); $('.btc').text(obj.resmath1); $('.xrp').text(obj.resmath2); $('.eth').text(obj.resmath3); $('.eos').text(obj.resmath4); $('.ltc').text(obj.resmath5); $('.xuc').text(obj.resmath6); $('.bth').text(obj.resmath7); $('.dash').text(obj.resmath8); var a = $('.ltc').text(); плоды моих фантазий// if( a > obj.resmath5 ){$('.ltc').addClass('green'); // }else{ // $('.ltc').addClass('red'); // } } }); } get(); setInterval(get, 1000); }); The ajax request itself is just as interesting as how to implement adding a class for a specific time.
HTML
<tr> <td><img style="width:30px;" src="images/Litecoin.png"/></td> <td>LTC</td> <td>Litecoin</td> <td class="ltc td"><center><img style="width:20px;" src="images/giphy.gif"></center></td> </tr>