473,321 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Selecting all elements with same class name

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....

Dec 8 '06 #1
7 3457
ASM
eg****@gmail.com 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>
<h2 class="normal">text 5</h2>

PS. I have access to prototype....
why not a panzer division ?
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 8 '06 #2
ASM wrote :
eg****@gmail.com 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>
<h2 class="normal">text 5</h2>

>PS. I have access to prototype....
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 ;)

--
Naixn
http://fma-fr.net
Dec 9 '06 #3
ASM
naixn a écrit :
>
YOu can also use :
getElementByClassName :)
don't know what it is
PS: I you have the panzer division you're talking abut, let me hear
about it, I
may need one ;)
here you are :
http://www.google.com/search?q=panzer
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 9 '06 #4
ASM wrote :
naixn a écrit :
>>
YOu can also use :
getElementByClassName :)
don't know what it is
Forget it... I said this out of the blue, and in fact, that was something
I was in a script. nothing official in Javascript...
>PS: I you have the panzer division you're talking abut, let me hear
about it, I
may need one ;)
here you are :
http://www.google.com/search?q=panzer
Do you deliver? :p

--
Naixn
http://fma-fr.net
Dec 9 '06 #5
ASM
naixn a écrit :
ASM wrote :
>naixn a écrit :
>>>
getElementByClassName :)

don't know what it is

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 ?)
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 9 '06 #6
naixn wrote on 09 dec 2006 in comp.lang.javascript:
YOu can also use :
getElementByClassName :)
You are missing an "s":

getElementsByClassName()

<http://javascript.about.com/library/bldom08.htm>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 9 '06 #7
ASM
Evertjan. a écrit :
>
getElementsByClassName()

<http://javascript.about.com/library/bldom08.htm>
Interesting,

Now we have one panzer :-)
and next step ?
(lost my manual : where is the button to fire ? )

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 9 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: thomas | last post by:
Hello all Im having problems with selecting subelements from a dynamic created RTF converted to a node-set: i have hardcodet this example: the xml structure: <xsl:variable name="test">
5
by: Axial | last post by:
Question: How to select columns from Excel-generated XML when some cells are empty. I've found examples where rows are to be selected, but I can't seem to extrapolate from that to selecting...
2
by: Novice | last post by:
Hi all, I have to decide on an XML structure going forward. The structure is going to house a large amount of data. In the past I've always just used the philosophy of "when in doubt use...
7
by: grwalker | last post by:
I have some classes that have the <Serializable()> attribute applied, which of course by default serializes the class properties as elements. What I would like to do is to be able to override this...
4
by: Chris Jones | last post by:
Does anyone know of a C#/ASP.NET Open File dialog that I can use in an aspx page that allows multiselect? I need to be able to select and upload numerous files. Is there a reason why MS has made...
6
by: Mike Wilson | last post by:
Dear Group, I have a heirarchical set of database tables, say - "order" and "order_type" and want to display a series of orders in a grid control, and in place of the order_type foreign key...
2
by: areef.islam | last post by:
Hi, I am kinda new to javascript and I am having this problem with selecting multiple options from a select tag. Hope someone can help me out here. here is my code...
1
by: jdhcards | last post by:
Hello, I've been banging my head against a problem all day without a solution, and I'm hoping you all can help. I've got a piece of XML that defines a set of elements in a flat list. Each of...
7
by: swami | last post by:
What is the query for selecting non duplicate elements for eg: no name age 1 siva 28 2 blair 32 3 mano 28 i want to select blair which hasn't got any duplicate...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.