Given the following statement:
$('#upLatImb').append('<span style="color:#F62817; text-decoration:blink">' + sprintf("%11.0f",fCargoLatMom).replace(/ /g,' ') + '</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,' ') + '</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.
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,' ') + '</span');
No concatenation here! This results in cleaner HTML/CSS and is better practice, and memorable, all at once.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With