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
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,'<span style="color:red">ABC</span>'); })})
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)
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.