Home > front end >  How to change color of a piece of text in Javascript?
How to change color of a piece of text in Javascript?

Time:12-22

At first, I apologize for such a basic question, but I'm really new to javascript and I needed to change the color of a script's loading percentage.

The script snippet is this one:

function showProgressMessage(e) {
        $('#progress').removeClass('red-text').html(e);
      }

showProgressMessage(fileName   ": Loading: "   Math.floor(100 * cnt / end)   "%");

How do I change the color of Math.floor(100 * cnt / end) "%"?

CodePudding user response:

You can wrap that part of the text inside a <span> that has its CSS color property set.

showProgressMessage(fileName   ": Loading: <span style='color: green;'>" 
                         Math.floor(100 * cnt / end)   "%</span>");

CodePudding user response:

I hope this will help you.

showProgressMessage(fileName   ": Loading: <span style='color: blue;'>"   Math.floor(100 * cnt / end)   "%</span>");
  • Related