[javascript] Question

Matt Warden mwarden at gmail.com
Sat Jul 30 20:13:36 CDT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Schalk Neethling wrote:
> Now, after all that. The problem is, the first time I click the link
> nothing happens. After that it works perfectly. I am new to javascript
> and I am sure I am overlooking something. Any help or pointers will be
> much appreciated. Thank you in advance!

I am pretty sure that .style is a reference to the style attribute of
the element. So, the first time you call the function, style.display
is empty if it is not defined in the element as such:

<foo style="display: block;"></foo>

And, since it's empty, it gets thrown into your else condition, when
then assigns: style2.display = 'block'. Now, the next time you call
the function, the .style.display property will indeed equal 'block'.


- --
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFC7CXAAQ0d4HGyPE8RAnBGAJ9+FbhzYJ0nN6yDAxPtMtkyx6KXtwCfWhHs
x8bB83IthT3usVFERHYJD7w=
=Yi/6
-----END PGP SIGNATURE-----



More information about the Javascript mailing list