i want to make this text "|| something 1 || something 2 || more || last one ||"
and then bold "|" all that string
then its became something this "|| something 1 || something 2 || more || last one ||"
I'm using typewriter text plugin from gsap this is my code
function boldString(str, substr) {
var strRegExp = new RegExp(substr, 'g');
return str.replace(strRegExp, '<b>' + substr + '</b>');
}
gsap.to('.lead', { duration: '3.5', delay: '2', text: boldString("|| something 1 || something 2 || more || last one ||", "|")
then give me this result after typewriter plugin successfully launch
"||||| |s|o|m|e|t|h|i|n|g| |1| ||||| |s|o|m|e|t|h|i|n|g| |2| ||||| |m|o|r|e| ||||| |l|a|s|t| |o|n|e| |||||"
but with some "|" are bold
I'm also modified my code into
return str.replace(substr, '<b>' + substr + '</b>');
then gave me this result
|| something 1 || something 2 || more || last one ||
this is my reference before: Bold part of String
Thank you
Aucun commentaire:
Enregistrer un commentaire