Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create my own color name

Given the following statement:

$('#upLatImb').append('<span style="color:#F62817; text-decoration:blink">' + sprintf("%11.0f",fCargoLatMom).replace(/ /g,'&nbsp;') + '</span');

I would like to do something like:

var problemcolor=0xF62817;
$('#upLatImb').append('<span style="color:problemcolor; text-decoration:blink">' + sprintf("%11.0f",fCargoLatMom).replace(/ /g,'&nbsp;') + '</span');

but that results in numerous html errors.

I could, of course, do a search and replace across all .js files to change the color, but I'd like to use logical names if possible and only change one statement per color.

I'm just barely above absolute novice level, so all suggestions are most welcome.

like image 950
Terry Avatar asked Dec 13 '22 07:12

Terry


1 Answers

It looks like you want something memorable for repetitive use?

Create a CSS class with the "color: #F62817" property and apply the class instead of inline styles, which aren't usually preferred.

So, your CSS:

.problemcolor {
    color: #F62817;
}

.blink {
    text-decoration: blink;
}

And your jQuery:

$('#upLatImb').append('<span class="problemcolor blink">' + sprintf("%11.0f",fCargoLatMom).replace(/ /g,'&nbsp;') + '</span');

No concatenation here! This results in cleaner HTML/CSS and is better practice, and memorable, all at once.

like image 171
Matt Avatar answered Dec 22 '22 01:12

Matt