Selecting all elements with same class name

E

eggie5

I have multiple elements with the same class ID. I want to Hide them
all, but I only know how to select one element at a time, e.g.
Element.hide('element). How can I do this to multiple elements with the
same id or class name?

PS. I have access to prototype....
 
A

ASM

(e-mail address removed) a écrit :
I have multiple elements with the same class ID.

with the same class or the same id ?
it is absolutely forbiden to have more than ONE element with same id !
I want to Hide them
all, but I only know how to select one element at a time, e.g.
Element.hide('element). How can I do this to multiple elements with the
same id or class name?

No you can't with same id because id is unique on a same page :-(

If elements are with same class :

You can create a special class for the body which will say to this class
: hop! hide !

<style type="text/css">
..normal { color: blue }
..hid .normal { visibility: hidden }
</style>
<script type="text/javascript">
function hidShw(){
document.body.className = document.body.className==''? 'hid' : ''; }
</script>
<div class="normal">text 1</div>
<div>
<p>text 2</p>
<p class="normal">text 3</p>
</div>
<p><button onclick="hidShw()">Hide/Show blue elements</button></p>
<h3>text 4</h3>
PS. I have access to prototype....

why not a panzer division ?
 
N

naixn

ASM wrote :
(e-mail address removed) a écrit :

with the same class or the same id ?
it is absolutely forbiden to have more than ONE element with same id !


No you can't with same id because id is unique on a same page :-(

If elements are with same class :

You can create a special class for the body which will say to this class
: hop! hide !

<style type="text/css">
.normal { color: blue }
.hid .normal { visibility: hidden }
</style>
<script type="text/javascript">
function hidShw(){
document.body.className = document.body.className==''? 'hid' : ''; }
</script>
<div class="normal">text 1</div>
<div>
<p>text 2</p>
<p class="normal">text 3</p>
</div>
<p><button onclick="hidShw()">Hide/Show blue elements</button></p>
<h3>text 4</h3>


why not a panzer division ?

YOu can also use :
getElementByClassName :)

PS: I you have the panzer division you're talking abut, let me hear aboutit, I
may need one ;)
 
A

ASM

naixn a écrit :
ASM wrote :

Forget it... I said this out of the blue,

I understood but now you have to give your function getElementByClassName()
for OP can follow, no ?

Do you deliver? :p

as soon as I'll've found the package
(how many dozens ?)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top