Inputing text via java into an HTML span container, like this:
<p><span id="myID" style="text-align: justify; display: block; font-style: italic;"></span>...
In the text I am inputing, in one case, a single word is not italic. How do I unitalicize the word?
document.getElementById("myID").style.fontStyle = "normal";
Modern front-end methods suggest you use CSS classes instead of inline styles in the markup.
Set the span to one main class identified by the id, and an italic class, and then use the JS to toggle the italic class off with classList.
// Cache the element, and set the innerText
const span = document.querySelector('#myID');
span.innerText = 'This is my text.';
// For an example wait one second to
// toggle the italic class
setTimeout(() => {
span.classList.toggle('italic');
}, 1000);
#myID { text-align: justify; }
.italic { font-style: italic; }
<p><span id="myID" class="italic"></span></p>