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


Groups > comp.lang.javascript > #22901

Re: How to change style from id to class?

X-Received by 10.50.124.9 with SMTP id me9mr16542235igb.4.1391157906884; Fri, 31 Jan 2014 00:45:06 -0800 (PST)
X-Received by 10.140.91.72 with SMTP id y66mr12035qgd.23.1391157906853; Fri, 31 Jan 2014 00:45:06 -0800 (PST)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!c10no7413090igq.0!news-out.google.com!y18ni189qap.1!nntp.google.com!k15no10842567qaq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.javascript
Date Fri, 31 Jan 2014 00:45:06 -0800 (PST)
In-Reply-To <e95d8eab-bb7c-41fe-85c6-305ada95babb@googlegroups.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=84.197.54.56; posting-account=DOKj1gkAAAC7ll60oTpinRGSlJa6g5IL
NNTP-Posting-Host 84.197.54.56
References <3105082e-9d14-4e82-a104-c1b34a9b571e@googlegroups.com> <iauke9pmho07mgqs1kdo11e63q5lbs5jnn@hive.bjoern.hoehrmann.de> <e95d8eab-bb7c-41fe-85c6-305ada95babb@googlegroups.com>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <e1e02de7-ca72-4060-a96a-e91cbd2337de@googlegroups.com> (permalink)
Subject Re: How to change style from id to class?
From Bart Van der Donck <bart@nijlen.com>
Injection-Date Fri, 31 Jan 2014 08:45:06 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.javascript:22901

Show key headers only | View raw


WanWan wrote:
 
> 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.

I think you're looking for the 'className' property, eg.

  <div id="id1" class="class1"> ... </div> 
  <input type="button" value="Change class"
   onClick="document.getElementById('id1').className='class2';">

Hope this helps,

-- 
 Bart

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