TEXT from <div> is undefined

I want to return PROJECT NAME and SITE NAME from this div :

<div data-test="-title&^%^&" class="primary-title">
        PROJECT NAME | SITE NAME
</div>

I used:

var divs = document.getElementsByClassName('primary-title');
console.log ("got divs", divs[0]);      /* returns the div correctly  */

      var text = divs[0].innerhtml;  /* returns "undefined" */

but divs[0].innerhtml is undefined...

nOOb..what am I doing wrong ?

Viestejä yhteensä

  • You need divs[0].innerHTML because DOM property names are case-sensitive.

Kirjaudu sisään tai Rekisteröidy kommentoidaksesi.