[Javascript] Accessing property values using getElementById

George Tsang web.listserv at gmail.com
Wed Nov 23 16:17:22 CST 2011


Greetings,

I have been experimenting with getElementById method to access individual
elements property values.

For example, in my test web page, I have <h1 id="id_h101"> tag's font-size
property set to 16px and <table id="id_tbl01"> tag's border-width set to
2px. Both via my CSS sheet in the <head> section.

However, when using a for - in loop to step through the respective style
object (document.getElementById('id_h101').style and
document.getElementById('id_tbl01').style), some properties are displayed
with default values of false or 0 but no values appeared for the <h1
id="id_h101"> tag's fontSize property or the <table id="id_tbl01"> tag's
borderWidth property or any other properties without a preset default value.

Although the values I set did take effect on my web page but why can't
getElementById('tagID').style show me the expected results?

Your advice and suggestions are greatly appreciated.

George


More information about the Javascript mailing list