“Dynamic HTML” talked a lot about the Document Object Model (DOM) and objects, which can seem pretty daunting at first, so let’s break it down to the simplest scale, that of CSS. Say you have a div element with a blue font inside it. To make the div (and its contents) accessible by script, you need to identify it somehow. You can do this using the id attribute of the <div> tag. The id attribute is available to every HTML element for this very reason. So you can write a div element like so:<div id=“myID” style=“color:blue”>I’m blue now, but I may not be later.</div>
If you load the preceding code fragment into Internet Explorer, your browser will render.When this text styled in CSS is clicked, it will change.
Listing shows some modification to the previous code fragment. This time, the this keyword isn’t used because another div object is created, along with an onClick event handler for that div object. When the new div object is clicked, the text in the div object labeled by the myID attribute gets bigger and turns red.
Note Listing only works in IE4 and later and Mozilla/Netscape with Gecko engines (Netscape 7 and later).
Accessing an Element by Drilling Down the DOM Hierarchy<html>
Notice in Listing the relationship between the myID attribute and the code that is executed by the onclick event. Normally, you’ll call a function from an onclick event. But you can also simply execute the script from the event handler, as well. You can see the changes in Figures.
This text can be changed by clicking the Click Here button.
When the button is clicked, the text changes.
The solutions for changing CSS shown so far are of limited use because they rely on Gecko’s and Internet Explorer’s interpretation of the object model, the latter of which deviates quite substantially from that of the W3C object model. They both share the same core object model defined by the Document Object Model of the W3C. However, Internet Explorer expands on the DOM by a substantial amount.
HTML Related Interview Questions
|XML Interview Questions||HTML 4 Interview Questions|
|HTML Interview Questions||HTML 5 Interview Questions|
|HTML DOM Interview Questions||Java Interview Questions|
|CSS Interview Questions||Java Abstraction Interview Questions|
|Dynamic HTML Interview Questions||XHTML Interview Questions|
Introducing The Web And Html
What Goes Into A Web Page?
Starting Your Web Page
Lines, Line Breaks, And Paragraphs
Page Layout With Tables
Introducing Cascading Style Sheets
Creating Style Rules
Padding, Margins, And Borders
Colors And Backgrounds
Tables Table Styles
Defining Pages For Printing
Dynamic Html With Css
Introduction To Server-side Scripting
Introduction To Database-driven Web Publishing
Creating A Weblog
Introduction To Xml
Xml Processing And Implementations
Testing And Validating Your Documents
Choosing A Service Provider
Uploading Your Site With Ftp
Publicizing Your Site And Building Your Audience
Maintaining Your Site
The Web Development Process
Developing And Structuring Content
Designing For Usability And Accessibility
Designing For An International Audience
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.