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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hide layer 1

Status
Not open for further replies.

derwent

Programmer
Joined
May 5, 2004
Messages
428
Location
GB
I have a div tag that is displayed on a page over content, when you click the close link in the div it should hide the div. Is this possible?

i.e.

<div style='display: block'>
content content content content content
<br /><br />
<a href='#' onclick='set display to none'>Close</a>
</div>

Thanks
 
you can do:

Code:
<div id="myId" style="display: block;">content content</div>
<a href="#" onclick="document.getElementById('myId').style.display = 'none'; return false;">Close</a>

there are other ways, this is just one.



*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
If you give your DIV an id (and remove the unnecessary "display:block" - DIVs have this by default):

Code:
<div id="myDiv">

then you can use:

Code:
onclick="document.getElementById('myDiv').style.display = 'none';"

Hope this helps,
Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top