Home > Enterprise >  how can i bold part of the text with js
how can i bold part of the text with js

Time:09-14

I'm doing the language translation of the html page with js. but I can't bold the sentence it takes in quotes because I'm using the "variable" code. I added the tag inside and outside the apostrophes, but it still didn't work. how can I do that.

CodePudding user response:

Put the variable in an html element (I assume you're already doing that), then give your element an ID (let's say "myelement"). Then use code like:

document.getElementById("myelement").style.fontWeight = "bold";

CodePudding user response:

Create an inner div/tag for just the text you want to be bold. Then you can apply custom styling to that text using style from document.getElementById

  • Related