views:

30

answers:

2

Hi, I can show/hide with IDs, however how do I do it with classes?

$('black').setStyle({
  display:'none', border:'1px solid red'
});

For example that will work if I had #black, but what if I have .black?

Thanks,

A: 

Try:

$$('.black').setStyle({
  display:'none', border:'1px solid red'
});

More Info:

http://www.prototypejs.org/api/utility/dollar-dollar

Sarfraz
Unfortunately I get. TypeError: $$(".black").setStyle is not a function { message="$$(".large-black").setStyle is not a function", more...} When $$(".black") returns 2 elements
pondpad
@pondpad: Make sure you are using latest version of prototype.
Sarfraz
Using 1.5.1.1, upgrading is not a option as various other parts rely on it.
pondpad
Just did test with the latest, function still does not work.
pondpad
I figured it, thanks for helping though!
pondpad
1.5.* is ancient!!!
seanizer
`$$(".black").setStyle`does not work with prototype. You are probably thinking of JQuery.
seanizer
+1  A: 

Got it!

$$('.black').each(
   function (e) {
      e.setStyle({border:'1px solid red'}); 
   } 
);
pondpad