Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #22891

Re: How to change style from id to class?

Newsgroups comp.lang.javascript
Date 2014-01-30 08:24 -0800
References <3105082e-9d14-4e82-a104-c1b34a9b571e@googlegroups.com> <iauke9pmho07mgqs1kdo11e63q5lbs5jnn@hive.bjoern.hoehrmann.de>
Message-ID <e95d8eab-bb7c-41fe-85c6-305ada95babb@googlegroups.com> (permalink)
Subject Re: How to change style from id to class?
From WanWan <jippijappo@hotmail.com>

Show all headers | View raw


I've already changed using javascript:

<div id='example'>...</div>
to
<div id='uniqueId1' class='example'>...</div>


Now the style no longer apply.
A possible solution is to change using javascript:

div#example { color: blue; ... }
to
div.example { color: blue; ... }

OR apply div#example to <div id='uniqueId1' class='example'> some other way.


kl. 17:12:22 UTC+1 torsdag 30. januar 2014 skrev Bjoern Hoehrmann følgende:
> * WanWan wrote in comp.lang.javascript:
> 
> >Hello, is there a way to change the style from a id item to class using javascript?
> 
> >
> 
> >For example:
> 
> >div#banana
> 
> >to
> 
> >div.banana
> 
> >
> 
> >After giving the item an unique id, the style no longer apply.
> 
> 
> 
> There are several ways to interpret your question. For instance, you
> 
> might have a style sheet with rules like
> 
> 
> 
>   div#example { color: blue; ... }
> 
> 
> 
> and want to use JavaScript to turn that into a style sheet like
> 
> 
> 
>   div.example { color: blue; ... }
> 
> 
> 
> It is also possible you have a document with an element like
> 
> 
> 
>   <div id='example'>...</div>
> 
> 
> 
> and want to turn that, using JavaScript, into
> 
> 
> 
>   <div class='example'>...</div>
> 
> 
> 
> It is also possible you are not asking about either problem. Could you
> 
> clarify what you are trying to accomplish?
> 
> -- 
> 
> Björn Höhrmann · mailto:xx@xx.xx· http://bjoern.hoehrmann.de
> 
> Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
> 
> 25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to change style from id to class? WanWan <jippijappo@hotmail.com> - 2014-01-30 07:43 -0800
  Re: How to change style from id to class? Bjoern Hoehrmann <bjoern@hoehrmann.de> - 2014-01-30 17:12 +0100
    Re: How to change style from id to class? WanWan <jippijappo@hotmail.com> - 2014-01-30 08:24 -0800
      Re: How to change style from id to class? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-30 20:17 +0100
        Re: How to change style from id to class? WanWan <jippijappo@hotmail.com> - 2014-01-30 12:33 -0800
      Re: How to change style from id to class? Bart Van der Donck <bart@nijlen.com> - 2014-01-31 00:45 -0800
        Re: How to change style from id to class? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-01-31 11:59 +0100
        Re: How to change style from id to class? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-31 13:55 +0100

csiph-web