The style Property


The style Property

You can use the style property to associate a CSS style with an element. You can see the support for this property in Table 5.53.

Table 5.53. The style Property

Property

NS2

NS3

NS4

NS6

IE3a

IE3b

IE4

IE5

IE5.5

IE6

style

     

x

   

x

x

x

x

 

Read/Write

 

Type: Object

The style property has many subproperties corresponding to the style attributes (such as color , fontWeight , and fontStyle ) that we'll see in Chapter 21, but here's a preview. In this example, I'll change the style of an <H1> header to italic when the user clicks a button:

(Listing 05-21.html on the web site)
 <HTML>      <HEAD>          <TITLE>Using the style Property</TITLE>          <SCRIPT LANGUAGE="JavaScript">              <!--                 function styler()                  {  document.body.style.fontStyle = "italic"  }              // -->          </SCRIPT>      </HEAD>      <BODY>          <H1 NAME="header1">Using the style Property</H1>          <FORM>              <INPUT TYPE="BUTTON" ONCLICK="styler()" VALUE="Click Me!">          </FORM>      </BODY>  </HTML> 

You can see the results in Figure 5.16.

Figure 5.16. Using the style property.

graphics/05fig16.gif



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net