Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28917
| From | Janis Papanagnou <janis_papanagnou@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Change all background-color attribute values |
| Date | 2015-11-23 16:01 +0100 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <n2v9ov$7ti$1@speranza.aioe.org> (permalink) |
| References | (1 earlier) <n2smdk$fkj$1@news.albasani.net> <n2sni1$9l0$1@speranza.aioe.org> <n2sov2$kq9$1@news.albasani.net> <n2stcn$p1t$1@speranza.aioe.org> <547d27f9-a9d0-4dfa-8301-6275a27f2b1b@googlegroups.com> |
On 22.11.2015 20:33, Scott Sauyet wrote:
> Janis wrote:
>> Martin Honnen wrote:
>>> document.getElementsByClassName('U') would give you all elements having that
>>> class 'U'.
>>
>> Ah, okay. So I understand that in this case I will have to do that for each
>> of the respective classes (more than a dozen) - i.e. there's no formal
>> shortcut -, and then also iterate over every element of the respective class
>> (about 10 elements per class) to change its respective value. I'll try this
>> as well. Thanks.
>
> Martin's other suggestion, of using the script access to the CSS rules, is
> probably a better bet. But if you choose this technique, while there is no
> formal shortcut, you could make it somewhat less painful by using something
> like
>
> var getByClass = document.getElementsByClassName.bind(document);
> var classes = ['U', 'V' /*, ... */];
> var elements = classes.map(getByClass);
>
> `elements` will now contain an array of HTMLCollections of elements matching
> one of your classes.
>
> -- Scott
>
Martin, Scott, Thomas, thanks for the additional clarifications and
suggestions. Indeed it seems much better to directly change the CSS rules,
which is exactly what I hoped to be possible. Good to know those methods.
Janis
PS:
As a note aside, I meanwhile also found an alternative approach to obtain
the function I want without tackling the DOM. I can use the "alternative
stylesheet" definition method and instead of writing own GUI controls and
DOM manipulations I can select the style changes from the browser menus
(i.e. [only] from those browsers that support this function). While not
as powerful as full control over the individual CSS rules, in my case
it's feasible to use this static method since I only have a small set of
CSS definitions to choose from. But this is off-topic here, so I posted
a question (about the concrete semantics in case of common definitions)
in the alt.html newsgroup.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Change all background-color attribute values Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-11-22 15:24 +0100
Re: Change all background-color attribute values Martin Honnen <mahotrash@yahoo.de> - 2015-11-22 16:19 +0100
Re: Change all background-color attribute values Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-11-22 16:38 +0100
Re: Change all background-color attribute values Martin Honnen <mahotrash@yahoo.de> - 2015-11-22 17:02 +0100
Re: Change all background-color attribute values Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-11-22 18:18 +0100
Re: Change all background-color attribute values Martin Honnen <mahotrash@yahoo.de> - 2015-11-22 19:27 +0100
Re: Change all background-color attribute values Scott Sauyet <scott.sauyet@gmail.com> - 2015-11-22 11:33 -0800
Re: Change all background-color attribute values Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-11-23 16:01 +0100
Re: Change all background-color attribute values JJ <jj4public@vfemail.net> - 2015-11-22 22:32 +0700
Re: Change all background-color attribute values JJ <jj4public@vfemail.net> - 2015-11-22 22:47 +0700
Re: Change all background-color attribute values Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-11-22 16:54 +0100
Re: Change all background-color attribute values Janis Papanagnou <janis_papanagnou@hotmail.com> - 2015-11-22 16:49 +0100
Re: Change all background-color attribute values Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-11-23 01:11 +0000
Re: Change all background-color attribute values Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-11-23 11:27 +0000
csiph-web