TEXT from <div> = undefined

80 views
Skip to first unread message

Colin Jones

unread,
May 10, 2019, 1:06:28 PM5/10/19
to greasemonkey-users


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

var divs = document.getElementsByClassName('primary-title');
console.log ("got divs", divs[0]);

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


                                                 
I'm trying to extract "PROJECT NAME" and "SITE NAME" from the <div>. above.

innerhtml returns "undefined"....

I'm a nooB so I'm obviously missing something....what ?


help ?

Andre Bernardo

unread,
May 11, 2019, 10:15:52 AM5/11/19
to greasemonkey-users
Properties names are case sensitive. Try innerHTML, instead of innerhtml.

Méhész György Ákos

unread,
May 11, 2019, 2:00:10 PM5/11/19
to greasemon...@googlegroups.com
Hi, the correct form is innerHTML, mind the case. If you only need the textual content, then you could use textContent or innerText, but the later has some issues in IE11.

--
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to greasemonkey-us...@googlegroups.com.
To post to this group, send email to greasemon...@googlegroups.com.
Visit this group at https://groups.google.com/group/greasemonkey-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/greasemonkey-users/3fc19f4e-bf94-4d8d-ac05-b89ca264f8e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages