JavaScript

msdsmd sm,dfsadf
PLUS
msdsmd sm,dfsadf
Courses Plus Student 1,013 Points

const child =document.createElement('span')// why can't I use div.createElement instead of document.createElement.

const child =document.createElement('span')// why can't I use 'div'  instead of document  

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Staff

Hi there, msdsmd sm,dfsadf! First, I'm assuming that div was defined as a Node element elsewhere. The createElement() method is available on the Document object but not on Node objects.

List of methods available on Document

List of methods available on an Element

List of methods available on a Node

The only list of those three that contains the createElement() method is the Document documentation :smiley:

Hope this helps! :sparkles: