-1

I'm trying to learn innerHTML commands, but it's just showing me "Author: " text.

HTML side

  <h1 id="author">Author: </h1>
  <p>Sabir Türkleri'nin ve Batı Göktürk boylarının devamı olan Hazarlar, Göktürk birliği döneminde Göktürklerin Batı kanadını oluşturmaktaydı.</p>
  </body>

JS side

   var content= "Ensar Ergok";
   document.getElementById("author").value=content;
Léo
  • 89
  • 1
  • 11
  • You haven't said whether you're getting an error, but as you said in the question, it's `innerHTML`, not `value`, for an `h1` element, see the [linked question's answers](https://stackoverflow.com/questions/11238508/how-to-get-value-of-a-div-using-javascript). If you did get an error message, it'll be because of [this](https://stackoverflow.com/questions/14028959/why-does-jquery-or-a-dom-method-such-as-getelementbyid-not-find-the-element). – T.J. Crowder Dec 05 '21 at 11:21
  • *(There has to be a better dupetarget for the `value`/`innerHTML` thing though.)* – T.J. Crowder Dec 05 '21 at 11:26

1 Answers1

0

You need to use innerText, textContent or innerHTML instead of value.

Michael Haddad
  • 4,085
  • 7
  • 42
  • 82