Hi,

> I'm using .addClassName and .setStyle to change body background. But
> my code doesn't work very well right now so I need to swich just
> to .setStyle . My question is: will .setStyle overwrite my existing
> style?

There's nothing like trying it to find out.

> Button 1 uses:
>  $$('body')[0].setStyle({background: 'url(someimage1.png) center
> center no-repeat;'});
>
> Button 2 uses:
>  $$('body')[0].setStyle({background: 'url(someimage2.png) center
> center no-repeat;'});
>
> So will this second command overwrite the existing style?

If you set the same style property on the same element (in this case
the document body), then yes, the second one overwrites (replaces) the
first.  It's just like setting the property of an object (in fact, it
*is* setting the property of an object).

BTW, it's OT, but take out that semicolon.  Semicolons are used in CSS
blocks to mark the end of a style definition, they are not part of the
style value.  Here you're giving the style value.

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available

On Jul 21, 1:23 am, wosd <webosdevelo...@gmail.com> wrote:
> Hi eveyone,
>
> I'm using .addClassName and .setStyle to change body background. But
> my code doesn't work very well right now so I need to swich just
> to .setStyle . My question is: will .setStyle overwrite my existing
> style?
>
> Example:
>
> Button 1 uses:
>  $$('body')[0].setStyle({background: 'url(someimage1.png) center
> center no-repeat;'});
>
> Button 2 uses:
>  $$('body')[0].setStyle({background: 'url(someimage2.png) center
> center no-repeat;'});
>
> So will this second command overwrite the existing style? If not - is
> there any way how to remove style? I know you can do it
> with .addClasName and .removeClassName, but I can't use them because
> my bg image path changes every time.
>
> Thanks for help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to