Good day,
I''m trying to use the slider control to resize a pile of images on a
web page. Clever, huh. Bet cha didn''t think of that one!!! :)
But seriously. It seems I want to address a class, rather than the
individual id''s of the images. At this point, I''m getting some
results with something like this:
onSlide:function(v){$(''item_428'').style.width =
(v*100)+"px"}
But that just addresses a single image (and doesn''t address the
height, but that''s another matter...). My first thought was to use
Prototype''s getElementsByClassName() to address all images of a given
class, but it seems you can''t just set them that way, only get an
array of them.
So my question is: am I barking up the wrong tree? Is there an easy
way to address CSS properties of a class of objects on a page, or do
I need to loop through them individually somehow? Has anyone tackled
this one?
Thanks,
Raymond
--
Raymond Brigleb, Needmore Designs
http://needmoredesigns.com/
sam-WNdku5qRq3FWk0Htik3J/w@public.gmane.org
2005-Dec-07 22:14 UTC
Re: Addressing a class, rather than an id?
Quoting Raymond Brigleb <ray-THGPwszTed5CpjqP0VxSwUEOCMrvLtNR@public.gmane.org>:> So my question is: am I barking up the wrong tree? Is there an easy > way to address CSS properties of a class of objects on a page, or do > I need to loop through them individually somehow? Has anyone tackled > this one? >If I understand your question right, take a look at the utils.js in Scriptaculous. It provides a set of functions for handling CSS classes under the Element.Class "namespace". E.g. Element.Class.add(element, "someclass") Element.Class.has, Element.Class.remove, etc. I''ve added a Element.Class.replace and a few other helpers, I''m sure you''ll find your own extensions necessary but its a useful start. hth Sam (-i-am)
On Dec 7, 2005, at 2:14 PM, sam-WNdku5qRq3FWk0Htik3J/w@public.gmane.org wrote:> If I understand your question right, take a look at the utils.js in > Scriptaculous. It provides a set of functions for handling CSS > classes under > the Element.Class "namespace". E.g. Element.Class.add(element, > "someclass") > Element.Class.has, Element.Class.remove, etc. I''ve added a > Element.Class.replace > and a few other helpers, I''m sure you''ll find your own extensions > necessary but > its a useful start.Thank you very much. To answer my question of earlier, something like this did it for me: onSlide:function(v){ for (var i = 0; i < document.images.length; i++) { if (document.images[i].name == "thumb") { document.images[i].style.width = (v*60 + 40)+"px"; } } } However, now I''ve moved on to trying to figure out why it breaks utterly in IE6 Win. The slider works fine, it''s just that no matter what I try, IE will only show one image per line!!! Argh! Back to the old drawing board! -ray
Raymond, check out the Behaviour library (http://bennolan.com/behaviour/). It proved very useful to me. Cheers, Victor On 12/7/05, Raymond Brigleb <ray@needmoredesigns.com> wrote:> Good day, > > I'm trying to use the slider control to resize a pile of images on a > web page. Clever, huh. Bet cha didn't think of that one!!! :) > > But seriously. It seems I want to address a class, rather than the > individual id's of the images. At this point, I'm getting some > results with something like this: > onSlide:function(v){$('item_428').style.width = (v*100)+"px"} > > But that just addresses a single image (and doesn't address the > height, but that's another matter...). My first thought was to use > Prototype's getElementsByClassName() to address all images of a given > class, but it seems you can't just set them that way, only get an > array of them. > > So my question is: am I barking up the wrong tree? Is there an easy > way to address CSS properties of a class of objects on a page, or do > I need to loop through them individually somehow? Has anyone tackled > this one? > > Thanks, > Raymond > -- > > Raymond Brigleb, Needmore Designs > http://needmoredesigns.com/ > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >-- Victor Jalencas <Victor.Jalencas@gmail.com> _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs