MCQ on Scripting Documents in Client Side JavaScript set-6

1) ........ method allows you to insert a string of arbitrary HTML markup "adjacent" to the specified element.

A. insertAdjacentHTML()

B. insertBeforeHTML()

C. insertAfterHTML()

D. insertAfterendHTML()


2) ..........property is used to insert plain text into a document without having to escape the angle brackets and ampersands used in HTML markup.

A. insertText

B. plainContent

C. textContent

D. plainText


3) ........... is similar to textContent property introduced by Microsoft for Internet Explorer browser.

A. insertText

B. plainContent

C. textContent

D. innerText


4) ........ does not return the content of <script> elements, also omits extraneous white-space and attempts to preserve table formatting.

A. insertText

B. innerText

C. textContent

D. plainContent


5) State whether the following statements about inserting element content as plain text are True or False.

i) The textContent and innerText properties are similar enough that we can usually use them interchangeably.

ii) innerText is treated as a read-only property for certain table elements such as <table>, <tbody> and <tr>

iii) The textContent property is a straightforward concatenation of all Text node descendants of the specified element.

A. i-True, ii-True, iii-False

B. i-True, ii-False, iii-False

C. i-True, ii-True, iii-True

D. i-False, ii-False, iii-True



6) To insert element content as Text Nodes, .......... property is read/write and you can set it to change the content displayed by a Text or CDATASection node.

A. nodeContent

B. nodeType

C. nodeText

D. nodeValue


7) We can create new element nodes with the ........ method of the document object which can pass the tag name of the element as the method argument.

A. createElement

B. createNode

C. createDocumentNode

D. createElementNode


8) Every node has ........... method that returns a new copy of the node and passes true to recursively copy all descendants as well, or false to only make a shallow copy.

A. importNode()

B. cloneNode()

C. copyNode()

D. passNode()


9) ........... returns a copy suitable for insertion into the document and passes true as the second argument to recursively import all descendants.

A. importNode()

B. cloneNode()

C. copyNode()

D. passNode()


10) ........ is invoked on the element node that you want to insert into, and it inserts the specified node so that it becomes the last child of that node.

A. insertBefore()

B. appendChild()

C. insertAfter()

D. appendNode()



11) .......... takes two arguments, the first argument is the node to be inserted and the second argument is the node before which that node is to be inserted.

A. insertBefore()

B. appendChild()

C. insertAfter()

D. appendNode()


12) State whether the following statements are True or False for inserting nodes.

i) If you pass null in the second argument, the insertBefore() behaves like appendChild() and inserts at the end.

ii) If you call appendChild() or insertBefore() to insert a node that is already in the document, that node will automatically be removed from its current position and reinserted at its new position.

A. i-True, ii-False

B. i-False, ii-True

C. i-False, ii-False

D. i-True, ii-True


13) A .......... is a special kind of node that serves as a temporary container for other nodes.

A. Document Node

B. Document Partial

C. Document Fragment

D. Document Temporary


14) .......... can have any number of children, which we can manipulate with appendChild(), insertBefore() and so on.

A. Document Node

B. Document Partial

C. Document Fragment

D. Document Temporary


15) The ........... method allows us to determine the current position of an element in a view-port.

A. getBoundingClientRect()

B. elementFromPoint()

C. getElementByTagName()

D. pageXoffset()


Answers:

1) A. insertAdjacentHTML()
2) C. textContent
3) D. innerText
4) B. innerText
5) C. i-True, ii-True, iii-True
6) D. nodeValue
7) A. createElement
8) B. cloneNode()
9) A. importNode()
10) B. appendChild()
11) A. insertBefore()
12) D. i-True, ii-True
13) C. Document Fragment
14) C. Document Fragment
15) A. getBoundingClientRect()

For more Multiple Choice Questions (MCQs): Click Here