I'm trying to add bold text to my website using javascript, but it literly shows the "<b>". How do i fix this?
var TextBox = document.getElementById("TextBox");
TextData.textContent = "<b> hello </b>"
I tried using the document.write(""); , but it changes the whole website. Any Suggestions?
You can add first the content to textbox like this:
TextBox.innerHTML = "Hello";
then add its style like this:
TextBox.style.fontWeight = 'bold';
Or you can do it setting the innerHTML property of the element, just like this:
TextBox.innerHTML = "<b>Hello</b>";
I tend to set style separately. You should avoid adding style like this, better use css classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With