Say we have HTML code that looks like this:<IMG SRC="start.gif" NAME="start">
Images, along with some other common elements, such as forms and links, get special treatment in the DOM, so they can be referenced using this simple syntax. For regular HTML elements, like headings and paragraphs, the technique is a bit different. Consider the following HTML document:<html><head><title>Sample Document</title></head><body><h1>An HTML Document</h1><p id="simple">This is a simple paragraph.</p></body></html>
getElementById( ) is a method, or built-in function, of the document object. It returns the HTML element with the specified id attribute in the document, which in this case is the paragraph we are interested in. The document object also has a number of other methods for accessing HTML elements, such as getElementsByTagName( ) and getElementsByName( ).
Just referencing an object isn't particularly interesting, however. What we really want to be able to do is manipulate the object, say by changing its appearance or location. One way to manipulate an object is to change its properties, which describe different characteristics of the object. In most cases, these properties actually correspond to attributes of the HTML element represented by the object. For example, an image object has a src property that corresponds to the src attribute of the <img> tag.
Table lists the DOM objects for some common HTML elements, along with some of their properties.
Table: DOM objects and their properties
With DHTML, the style property is by far the most important property. It lets you access all of the CSS properties that apply to a particular element, so you can use it to change things like the color, font family, and font size of an element. For example, here's how we can change the color of our simple paragraph to green:document.getElementById("simple").style.color = "00FF00";
Web Designing Related Interview Questions
|HTML Interview Questions||HTML 5 Interview Questions|
|Flash Interview Questions||Graphic Design Interview Questions|
|Illustrator Interview Questions||Dreamweaver Interview Questions|
|UI Developer Interview Questions||Dreamweaver CS3 Interview Questions|
|CSS Advanced Interview Questions||Web Developer Guide Interview Questions|
|Log Shipping Interview Questions||Spring Boot Interview Questions|
|UI Designer Interview Questions||Bootstrap 4 Interview Questions|
Web Designing Related Practice Tests
|HTML Practice Tests||HTML 5 Practice Tests|
|Flash Practice Tests||Graphic Design Practice Tests|
|Illustrator Practice Tests||Dreamweaver Practice Tests|
|UI Developer Practice Tests||Dreamweaver CS3 Practice Tests|
|Web Developer Guide Practice Tests||Advanced jQuery Practice Tests|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.