Check out Scrivo

Do you want to try out Scrivo? Then here's a demo for you that does not just get your feet wet but lets you plunge right in.

Contact us

For more information, please contact us. We're happy to help you out!

Next Oct 27 Previous

Elementary node stuff

Which of the following functions will create DOMElement objects. Choose all that apply.

A: createComment()
B: createElement()
C: createElementNS()
D: createTextNode()

Answer

All four functions return an object of type DOMNode but only B: createElement() and C: createElementNS() return DOMElements. Take a good look at this (incomplete) DOMNode inheritance tree, it should be second nature to you:

  • DOMNode
    • DOMAttr
    • DOMCharacterData
      • DOMComment
      • DOMText
        • DOMCDATASection
    • DOMDocument
    • DOMDocumentFragment
    • DOMDocumentType
    • DOMElement
    • DOMEntity
    • DOMEntityReference