Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toggle elements visibility with the same ID?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Hi, (newbie alert!)

<input type=&quot;button&quot; onclick=&quot;document.all.hideMe.style.visibility= 'hidden';&quot;>

<div id=&quot;hideMe&quot;></div>

..this would hide the div on button click.

But how could I hide several elements that have the same id? - also it must be inline code, like above.

Such as -

<div id=&quot;hideMe&quot;>Hide me on button click</div>
<div id=&quot;hideMe&quot;>Hide me also on button click (with same id)</div>

Cheers,

Dave



 
Hi there ,
one way to do it is to put your div's in a form
and do the hide event to the whole form
like this exemple-

<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
</HEAD>
<BODY>
<input type=&quot;button&quot; onclick=&quot;document.all.i.style.display='none'&quot;>
<BR> 
<FORM name=&quot;i&quot;>  
<div id=&quot;hideMe&quot;>Hide me on button click</div>
<BR>  
<div id=&quot;hideMe&quot;>Hide me also on button click</div>
</FORM>
</BODY>
</HTML>
the things that you need to hide you put inside the form
there must be an different way to do so if that's not
working for you let me know - i'll think of something else.
Hendrix.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top