Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #15475
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Altering what a class does |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | <ZbqZfMCjRpMQFwp9@invalid.uk.co.demon.merlyn.invalid> <52cf4acb-1059-495c-bab5-bedada4befd5@oi9g2000pbb.googlegroups.com> |
| Message-ID | <XnsA0B6658E69A42eejj99@194.109.133.133> (permalink) |
| Date | 2012-08-21 07:59 +0000 |
dhtml wrote on 21 aug 2012 in comp.lang.javascript:
> On Aug 20, 12:47 pm, Dr J R Stockton
> <reply1...@merlyn.demon.co.uk.invalid> wrote:
>> In the Head of a page, I have
>>
>> <link rel="StyleSheet" href="styles-a.css" type="text/css">
>>
>> <style type="text/css">
>> /* more classes */
>> .JAX { display: none }
>> /* maybe more classes */
>> </style>
>>
>> At the press of a button, I wish to alter JAX to { display: block } -
>> or to just { } or to remove the rule; the button already has an
onclick
>> handler.
>>
>> It would save me some cogitation if the necessary code were supplied.
>>
> Change the element's `className` property.
>
> if(el.className == 'JAX') {
> el.className = 'POOTER';
>}
>
> .POOTER {
> background: oldlace;
>}
>
Methinks John wants to change some rule in an existing class,
so in all elements using that class,
not changing the className of numerous elements.
==========================================
<script type='text/javascript'>
function toggle(sh,rl,c1,c2) {
var stsh = document.styleSheets[sh];
var rul = stsh.cssRules || stsh.rules;
var rgx = new RegExp(rl,'i');
for (i=0;i<rul.length;i++)
if (rgx.test(rul[i].selectorText))
myRul = rul[i];
myRul.style.color = (myRul.style.color != c1) ?c1 :c2 ;
};
</script>
<style type='text/css' id='styleA'>
.nav {color:navy;}
</style>
<style type='text/css' id='styleB'>
.JAX {color:purple;}
.gr {color:green;}
</style>
<div class='JAX'
onclick="toggle('styleB',this.className,'purple','red');">
Click me to toggle
</div>
<div class='gr'>
green
</div>
<div class='JAX'>
1 2 3
</div>
<div class='nav'>
navy
</div>
==========================================
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Altering what a class does Dr J R Stockton <reply1234@merlyn.demon.co.uk.invalid> - 2012-08-20 20:47 +0100
Re: Altering what a class does dhtml <dhtmlkitchen@gmail.com> - 2012-08-20 16:12 -0700
Re: Altering what a class does "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-08-21 07:59 +0000
Re: Altering what a class does Dr J R Stockton <reply1234@merlyn.demon.co.uk.invalid> - 2012-08-23 19:54 +0100
Re: Altering what a class does "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-08-23 23:01 +0000
Re: Altering what a class does Dr.Kral@nyc.rr.com - 2012-08-23 13:16 -0400
Re: Altering what a class does "Tom de Neef" <tdeneef@qolor.nl> - 2012-08-24 19:18 +0200
Re: Altering what a class does Scott Sauyet <scott.sauyet@gmail.com> - 2012-08-29 13:33 -0700
Re: Altering what a class does Dr J R Stockton <reply1235@merlyn.demon.co.uk.invalid> - 2012-08-30 22:19 +0100
Re: Altering what a class does Scott Sauyet <scott.sauyet@gmail.com> - 2012-08-31 20:39 -0700
Re: Altering what a class does "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-09-01 08:23 +0000
Re: Altering what a class does Dr J R Stockton <reply1235@merlyn.demon.co.uk.invalid> - 2012-09-02 19:49 +0100
Re: Altering what a class does Scott Sauyet <scott.sauyet@gmail.com> - 2012-09-03 15:45 -0700
Re: Altering what a class does Gene Wirchenko <genew@ocis.net> - 2012-09-03 17:13 -0700
Re: Altering what a class does Dr J R Stockton <reply1236@merlyn.demon.co.uk.invalid> - 2012-09-04 21:10 +0100
Re: Altering what a class does Dr J R Stockton <reply1236@merlyn.demon.co.uk.invalid> - 2012-09-06 23:37 +0100
csiph-web