Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #16177
| From | Gregor Kofler <usenet@gregorkofler.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Question about reference to style properties |
| Date | 2012-09-27 10:08 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <k411ie$91d$1@dont-email.me> (permalink) |
| References | <50640679$0$6987$e4fe514c@news2.news.xs4all.nl> |
Am 2012-09-27 09:55, Erwin Moller meinte:
> Hi clj,
>
> Please consider the following 2 examples:
>
> Example1: (works as intended)
> =========================================================
> <span class="ahrefmimic"
> onClick="var curStyle =
> document.getElementById('techdiv').style;
> curStyle.display=((curStyle.display=='block')?'none':'block');
> ">on/off</span>
> <div id="techdiv" style="display:none;">
> ....
> </div>
> =========================================================
>
>
> Example2: (Doesn't work as intended, but no errors)
> =========================================================
> <span class="ahrefmimic"
> onClick="var curStyleDisp =
> document.getElementById('techdiv').style.display;
> curStyleDisp=((curStyleDisp=='block')?'none':'block');
> ">on/off</span>
> <div id="techdiv" style="display:none;">
> ....
> </div>
> =========================================================
>
>
> Example 1 works as (I) intended: It makes div techdiv appear and
> disappear when clicking on 'on/off'.
> The second example doesn't do anything (no error message either).
>
The first one establishes a reference to your style object (I'm sure I
got my wording wrong - Thomas will correct that :-) ) and you access and
set a property of this object.
In the latter case you assign a string value to a variable and overwrite
this value depending on its previous value. There is no longer a
reference to your style object established.
> In example2, am I just changing the value of a String that has no
> connection to the original style.display property?
Yes. How should it?
Gregor
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Question about reference to style properties Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-09-27 09:55 +0200
Re: Question about reference to style properties Gregor Kofler <usenet@gregorkofler.com> - 2012-09-27 10:08 +0200
Re: Question about reference to style properties Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-09-27 10:25 +0200
Re: Question about reference to style properties Gregor Kofler <usenet@gregorkofler.com> - 2012-09-27 14:03 +0200
Re: Question about reference to style properties Martin Honnen <mahotrash@yahoo.de> - 2012-09-27 14:01 +0200
Reference basics (Was: Question about reference to style properties) Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-09-27 14:46 +0200
Re: Reference basics (Was: Question about reference to style properties) Martin Honnen <mahotrash@yahoo.de> - 2012-09-27 15:09 +0200
Re: Reference basics (Was: Question about reference to style properties) Gregor Kofler <usenet@gregorkofler.com> - 2012-09-27 15:16 +0200
Re: Reference basics (Was: Question about reference to style properties) Scott Sauyet <scott.sauyet@gmail.com> - 2012-09-27 06:35 -0700
Re: Reference basics (Was: Question about reference to style properties) Scott Sauyet <scott.sauyet@gmail.com> - 2012-09-27 06:42 -0700
Re: Reference basics (Was: Question about reference to style properties) Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-10-01 09:14 +0200
csiph-web