dynamically change color of a live value in html [closed]

I want to dynamically change the color of a output value in my html like I do in Node-Red with:

a) template

<style>
    .plus {
        color: red !important;
    }
</style>

b) dashboard

{{msg.payload.P > 0 ? '<span  class="plus">' + msg.payload.P  + '</span>' : msg.payload.P}} W

here I want to change “P” dynamically.

I want “P” to be darkgreen if it is < 0.

but I don’t know the code for HTML with :

            <td id="P"></td>
            <td>W</td>

Link to my page

  • 3

    Something in my web site or project doesn’t work. Can I just paste a link to it?

    – 

  • 2

    Hi! Welcome to StackOverflow! Please take a look at our tour to get a better understanding about how to ask a good question. Afterwards, please edit your question to add all the relevant code.

    – 

Leave a Comment