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


Groups > comp.lang.javascript > #14304

Re: Changing styles values by Element Name

From Scott Johnson <noonehome@chalupasworld.com>
Newsgroups comp.lang.javascript
Subject Re: Changing styles values by Element Name
Date 2012-06-03 09:06 -0700
Organization A noiseless patient Spider
Message-ID <jqg229$edj$1@dont-email.me> (permalink)
References <jqfps1$r9j$1@dont-email.me> <4fcb6c56$0$6573$9b4e6d93@newsspool3.arcor-online.net> <XnsA067B487E79B6eejj99@194.109.133.133>

Show all headers | View raw


On 6/3/2012 8:44 AM, Evertjan. wrote:
> Martin Honnen wrote on 03 jun 2012 in comp.lang.javascript:
>
>> Scott Johnson wrote:
>>
>>> function select(oElement) {
>>>
>>> document.getElementsByName('color_swatch').style.border = "1px solid
>>> gray"; oElement.style.border = "3px solid red";
>>> }
>>>
>>> This is barfing on setting the 'name' style.
>>
>> You need to loop e.g.
>>     for (var imgs = document.images.color_swatch, l = imgs.length; i<
>>     l;
>> i++) {
>>       imgs[i].style.border = "1px solid gray";
>>     }
>> (respectively with getElementsByName
>>     for (var imgs = document.getElementsByName("color_swatch"), l =
>> imgs.length; i<  l; i++) {
>>       imgs[i].style.border = "1px solid gray";
>>     }
>>
>
>
> Better just replace the borderColor with "transparent",
> keeping the layout [bordersize] the same.
>
> [css]
> myImgs {border:3px solid transparent;}
>
> [js]
> var imgs = document.getElementsByName('color_swatch');
> var l = --imgs.length;
>
> function select(im) {
>     for (i=l, i<0; i--)
>        imgs[i].style.borderColor = "transparent";
>     im.style.borderColor = "red";
> };
>
>

Thanks for the quick reply.
You all are good!

Scotty

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


Thread

Changing styles values by Element Name Scott Johnson <noonehome@chalupasworld.com> - 2012-06-03 06:46 -0700
  Re: Changing styles values by Element Name Martin Honnen <mahotrash@yahoo.de> - 2012-06-03 15:53 +0200
    Re: Changing styles values by Element Name "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-06-03 15:44 +0000
      Re: Changing styles values by Element Name Scott Johnson <noonehome@chalupasworld.com> - 2012-06-03 09:06 -0700
      Re: Changing styles values by Element Name Scott Johnson <noonehome@chalupasworld.com> - 2012-06-03 09:22 -0700
        Re: Changing styles values by Element Name Jeremy J Starcher <r3jjs@yahoo.com> - 2012-06-05 20:26 +0000
          Re: Changing styles values by Element Name Scott Johnson <noonehome@chalupasworld.com> - 2012-06-05 20:52 -0700
            Re: Changing styles values by Element Name "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-06-06 09:57 +0000
              Re: Changing styles values by Element Name Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-09 11:43 +0200
                Re: Changing styles values by Element Name Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-09 13:03 +0200
                Re: Changing styles values by Element Name "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-06-09 14:14 +0000
                Re: Changing styles values by Element Name Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-09 18:13 +0200
                Re: Changing styles values by Element Name Luuk <luuk@invalid.lan> - 2012-06-09 18:35 +0200
                Re: Changing styles values by Element Name "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-06-10 10:33 +0000
                Re: Changing styles values by Element Name Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-10 14:50 +0200
  Re: Changing styles values by Element Name SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-06-04 15:32 +0200

csiph-web