?Explain the syntax to reference objects in JavaScript.

What will be an ideal response?


?Each object within a hierarchy is referenced by its object name such aswindow, document, or navigator.Because every object aside from the window object is?nested within other objects, they can be referenced using the?notation,                                                             object1.object2.object3...
whereobject1is at the top of the hierarchy,object2is a child ofobject1, and so on.Thus, to reference the images object nested within the window and document object, one would use the JavaScript expressionwindow.document.imagesTo reference a specific member of an object collection, we can use either                 collection[idref]or                 collection.idrefwherecollectionis a reference to the object collection, andidrefis either an index number representing the position of the object in the collection or the value of theidattribute assigned to the element. The first object in the collection has an index number of 0 with subsequent objects given index numbers of 1, 2, 3, and so on.Object collections can also be based on tag names using the expression,document.getElementsByTagName(tag)wheretagis the name of an HTML element.Object collections can also be formed from HTML elements belonging to the same class by using the expressiondocument.getElementsByClassName(class)whereclassis the value of the class attribute from the HTML document.Another, more efficient approach, is to reference an element by itsidornameattribute, using the expressiondocument.getElementsByName(name)
document.getElementById(id)Only one object is returned, not a collection, because each id value is unique within an HTML document.

Computer Science & Information Technology

You might also like to view...

What are the two types of networking devices defined by power over Ethernet? (Select all that apply.)

A) Powered sinking equipment B) Powered end users C) Powered sourcing equipment D) Powered device

Computer Science & Information Technology

Power is calculated as

A) Amps X farads B) Amps X ohms C) Volts X amps D) Volts X ohms

Computer Science & Information Technology

When talking about the form factor of a motherboard, we are actually talking about the size of the computer case

Indicate whether the statement is true or false

Computer Science & Information Technology

?Atransparentinterface does not distract a user and calls no attention to itself.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology