change font color based on condition

Hi

I checked this page
https://www.wix.com/corvid/forum/community-discussion/change-font-color-based-on-condition

but

I want to change the text color only 1 word inside the textbox.
[abcdefg “Availability” hijklm]
This code can change color only this text
[ “Availability” ]
Please tell me the code can change color only 1 word.
Thank you

Hi,

You can try using one of the following JS methods within your condition to check for a specific word in a string and then set its inline style as you did.

Try these out:
substring()
regex
includes()

Let me know if that works out for you.

My code is

import wixData from ‘wix-data’ ;
$w.onReady( function () {
$w( “#dynamicDataset” ).onReady( () => {

let txt =$w( “#text44” ).text;
$w( “#text44” ).html = txt.replace(/ABC/g, ‘ABC’ );

    })}) 

this code can change the color only 1 word but the fonts size change.
And the other fonts color become black (Original color was white)