Home > Enterprise >  change color of replaceAll comma with arrow
change color of replaceAll comma with arrow

Time:06-30

I have used replaceAll function which is perfectly working - I want to change the color of arrows. How can I do that? Please help I am a beginner.

Here is my jQuery code

let network = '';
if ($('#depsTo').val()) {
    network = $('#depsTo').val();
    network = network.toString().replaceAll(',','--->');
    console.log("NETWORK : "   network);
    $('#networkHeading').html(network);
}

CodePudding user response:

Just use html! You could use span, as I have in this snippet:

let network = 'This, is, a, test, string';
  network = network.toString().replaceAll(',','<span style="color:red">---></span>');
$('#networkHeading').html(network);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="networkHeading"></div>

CodePudding user response:

If you want same color again and again then use this

$('#'   id).css({"color":"blue"});

And if you want different color every time then use this in for loop

 var r = Math.random() * 256
 var g = Math.random() * 256
 var b = Math.random() * 256

$('#'   id).css({"color":`"rgba(${r},${g},${b},${a})"`});
  • Related