Skip to main content
Known Participant
September 3, 2020
Answered

Text color

  • September 3, 2020
  • 1 reply
  • 762 views

Can javascript be used to change color of part of the text.

Example: today was sunny day.

can word "sunny" be yellow and rest of the text default color (black).

I already tried CTRL+E but text in textbox is dynamic and it reset to default when changed.

This topic has been closed for replies.
Correct answer try67

Yes, this can be done by setting the field as having Rich Text Formatting and then setting its richValue property as an array of Span objects, each one representing a contiguous string of text with identical properties.

In this case you would have 3 spans:

- "today was " would be a Span with black text.

- "sunny" would be a Span with yellow text.

- " day." would be a Span with black text.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
September 3, 2020

Yes, this can be done by setting the field as having Rich Text Formatting and then setting its richValue property as an array of Span objects, each one representing a contiguous string of text with identical properties.

In this case you would have 3 spans:

- "today was " would be a Span with black text.

- "sunny" would be a Span with yellow text.

- " day." would be a Span with black text.

MarietaaAuthor
Known Participant
September 3, 2020

Thanks again Try67 you'r the best.