Richard Richard - 27 days ago 7
HTML Question

Set text in HTML paragraph from javascript function without formatting

How can I add text to a HTML paragraph without adding formatting to the inserted text? This is what I have so far:



<p>Example paragraph <ins id="example"></ins>.</p>
<script>
function getIt() {
return "it"
}
document.getElementById("example").innerHTML = getIt();
</script>





When the word "it" is inserted, it is underlined. How dow I prevent it from being underlined?

Thank you!

Answer Source

ins{
  text-decoration: none;
}
<p>Example paragraph <ins id="example"></ins>.</p>
<script>
  document.getElementById("example").style.textDecoration = "none";
  function getIt() {
          return "it"
  }
  document.getElementById("example").innerHTML = getIt();
</script>

You should set text-decoration: none;