Skip to main content
Known Participant
Sep 3, 2020 8:06 PM UTC
Answered

Text color

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 is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Sep 3, 2020 8:21 PM UTC

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.

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Sep 3, 2020 8:21 PM UTC

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.

Translate
MarietaaAuthor
Known Participant
Sep 3, 2020 8:27 PM UTC

Thanks again Try67 you'r the best.

Translate