How js displays different colors according to the positive and negative elements in table

problem description

the table is as follows

< table id= "coinmarket" > < thead > < tr > < th > ranking < / th > < th > currency < / th > < th > currency name < / th > < th > Price (USD) < / th > < th > Market capitalization (USD) < / th > < th > current turnover < / th > < th > Total issuance < / th > < th > 24-hour ups and downs (%) < / th > < th > 24-hour trading volume < / th > < th > 24-hour average price < / th > < / tr > < / thead > < tbody > {{range .Data}} < tr class= "coin-tr" onmouseover= "this.style.background="- sharpfbe8d5"" style= "cursor: pointer" Onmouseout= "this.style.background=""" > < td class= "coin-td" > {{.Rank}} < / td > < td id= "symbol" > {{.symbol}} < / td > < td > {{.Name}} < / td > < td > {{.PriceUsd}} < / td > < td > {{.MarketCapUsd}} < / td > < td > {{.supply}} < / td > < td > {{.MaxSupply}} < / td > < td id= "changePercent" class= "change" > {{.ChangePercent24Hr}} < / td > < td > {{.VolumeUsd24Hr}} < / td > < td > {{.Vwap24Hr}} < / td > {{end}} < / tbody > < / table >

demand is based on the table table, the eighth column of the number positive or negative change the color of the number display. For example,

the environmental background of the problems and what methods you have tried

golang is used in the background, and an array is passed to the front end, which needs to show the elements all the time. I don"t know much about js. I tried several methods but failed. I don"t know how to find all the elements in that column in the table table.

related codes

{{.ChangePercent24Hr}}</td>
                        <td>{{.VolumeUsd24Hr}}</td>
                        <td>{{.Vwap24Hr}}</td>
                    </tr>
                {{end}}
                </tbody>
            </table>

I hope that all the positive numbers in the 24-hour up and down column will show red and the negative numbers will show green.

I don"t know much about js. I tried several methods without success. I would appreciate it under the guidance of God here. Thank you!

Jan.08,2022


$('.change').each(function(i){
    var colorStr = ''; 
    $('.change').eq(i).html()>0 ?  colorStr = 'red' : 'green';
    $('.change').eq(i).css('color',colorStr );
});

requires a jQyery js library

$(function(){
    $('.change').each(function(i){
        var colorStr = ''; 
        $('.change').eq(i).html()>0 ?  colorStr = 'red' : 'green';
        $('.change').eq(i).css('color',colorStr );
    });
})

I don't understand the rendering syntax of golang, but since I can render the data normally, I should be able to judge it.

when rendering, judge whether .ChangePercent24Hr is positive or negative, and give td different class

.
.positive {
    color: -sharpfb3d3d; // 
}
.negative {
    color: -sharp04be02; // 
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bfd1fa-3233b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bfd1fa-3233b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?