I have two variable strings which i am combining into one string and then displaying it on screen. How do i make stringTwo bold text while leaving the other StringOne plain text ?
$w(‘#pageText’).text = ( stringOne + stringTwo);
I have two variable strings which i am combining into one string and then displaying it on screen. How do i make stringTwo bold text while leaving the other StringOne plain text ?
$w(‘#pageText’).text = ( stringOne + stringTwo);
You can use $w.Text.html . See the examples for possible scenarios.
@yisrael-wix
I’m having trouble applying this to my above issue. Can you give me an example of how i would make one of those strings bold using $w.Text.html
@mikemoynihan99 You want something like this:
let string1 = "Regular text";
let string2 = "<b>Bold Text</b>";
$w("#pageText").html = string1 + " " + string2;
@yisrael-wix
Sorry Yisrael I can not apply that to my above issue. That method would require me to be physically typing in the in the string value with some in line styling.
What I have are 2 variable strings. As they are variables they are derived from code hence I can not type in their values and perform inline styling.
@mikemoynihan99 I was only demonstrating how it’s done. You can create the strings programmatically. For more information, see the article Text Formatting .
That was quite a lengthy link you posted there, however i read through it all and did not see anything related to my specific issue.
@mikemoynihan99 See Text Formatting for information on how to create and format text in Javascript.
@yisrael-wix
I don’t need to read it a second time, once was enough. I’ll try to find a solution to my issue elsewhere.
@mikemoynihan99 Not sure what you’re looking for, but all of the information that you need is in both links that I posted.
@yisrael-wix
The links are identical
@mikemoynihan99 The two links I’m referring to:
$w.Text.html (the Wix Text component)
Text Formatting (MDN web docs)
For anyone that is reading this thread wondering how solve this issue the following solution from stackoverflow.com can be implemented:
$w(’ #pageText ').text = (stringOne + stringTwo);
$w(“# pageText “).html=””+ $w("# pageText “).text.slice(0,5) + “” + “” + $w(”# pageText ").text.slice(5,100) + “”;
Hey Mike - nice.
You can simplify by just formatting the text and then assigning to the text field:
let text = stringOne + stringTwo;
$w(“#pageText”).html = “” + text.slice(0,5) + “” + “” + text.slice(5,100) + “”;