Hi,
basically this is a generic problem.
What you want to do is to pass an enumeration of elements to the function:
(document.getElementsByClassName('testlabel')).each(function(e){new
Effect.Highlight(e,
{startcolor:'#ff99ff', endcolor:'#999999'})})
or nicer formatted :)
var elements = document.getElementsByClassName('testlabel');
elements.each( function(e){
new Effect.Highlight(e,{startcolor:'#ff99ff', endcolor:'#999999'})
} );
I was wondering if there is a more performant way to do:
(document.getElementsByClassName('className')).each(function(e){Element.hide(e)})
as element.hide also accepts multiple arguments.
Ah and a side note. getElementsByClassName also accepts regular expressions.
document.getElementsByClassName('testClass(_(\\d)+)')
will find you classes: testClass_1 test Class_34 etc...
.: Fabian
-----Ursprüngliche Nachricht-----
Von: [email protected]
Gesendet: 05.01.07 12:00:48
An: "Ruby on Rails: Spinoffs" <[email protected]>
Betreff: [Rails-spinoffs] Effect.Highlight
Hi,
Got a bit of a brain fart here... I would like to highlight a set of
DIV's (ideally by defined class name as it suits our development
process). I have the following functioning code:
However it only ever highlights the first testlabel div, not them all,
which is is expected as ID's should be unique I guess. How would I
make it so the highlighting which takes place can actually highlight
them all by defined class name so all DIV's assigned with the class
"testlabel" are actually highlighted?
Thanks
Code
-------
<a href="" onMouseOver="Effect.Highlight('testlabel',
{startcolor:'#ff99ff', endcolor:'#999999'})">Edit Labels (by ID)</a>
<h1> By ID </h1>
<div id="testlabel">foo</div>
<div id="testlabel" >foo</div>
<div id="testlabel">foo</div>
<div id="testlabel">foo</div>
<div id="testlabel">foo</div>
<h1>By Class</h1>
<div class="testlabel">foo</div>
<div class="testlabel" >foo</div>
<div class="testlabel">foo</div>
<div class="testlabel">foo</div>
<div class="testlabel">foo</div>
_______________________________________________________________________
Viren-Scan für Ihren PC! Jetzt für jeden. Sofort, online und kostenlos.
Gleich testen! http://www.pc-sicherheit.web.de/freescan/?mc=022222
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on
Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---