Collections all and children
• Included
arrays of related objects on a page The Dynamic HTML Object Model, includes a
special collection, all. The all collection is a collection of all the XHTML
elements in a document, in the order in which they appear. This provides an
easy way of referring to any specific element, especially if it does not have
an id.
• The
script in iterates through the all collection and displays the list of XHTML
elements on the page by writing to the innerHTML property of a p element.
Dynamic Styles
• An
element‘s style can be changed dynamically. Often such a change is made in
response to user events. We refer to the background color as document.
body.style.backgroundColor—the body property of the document object refers to
the body element.
• Then use
the style object (a property of most XHTML elements) to set the
background-color CSS property. (This is referred to as backgroundColor in
JavaScript, to avoid confusion with the subtraction (-) operator. This naming
convention is consistent for most of the CSS properties.
Dynamic Positioning
• XHTML
elements can be positioned with scripting. This is done by declaring an
element‘s CSS position property to be either absolute or relative, and then
moving the element by manipulating any of the top, left, right or bottom CSS
properties.
• vary the
position of the element on the page by accessing its CSS left attribute, we use
scripting to vary the color, fontFamily and fontSize attributes, and we use the
element‘s innerHTML property to alter the content of the element.
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.