| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Now Freelance!
Join Date: Aug 2006
Location: Warrington, UK
Posts: 476
|
Show/Hide Content
I am currently working on a site and would like to add a show/hide content link on a div so when it is clicked, the user can do either. I have been looking at MooTools to do this but am not too sure about how to do it. I was just wondering if anyone could recommend the best way this could be done? |
|
|
|
|
|
#2 (permalink) |
|
shiro
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 2,606
|
make the html look like this: Code:
And make your javascript look like this: Code:
|
|
|
|
#3 (permalink) |
|
Semantics, yay.
Join Date: Nov 2005
Location: Salem, Massachusetts
Posts: 1,128
|
Just remember that the language attribute has been deprecated. Use type instead: <script type="text/javascript"> function show() { var targetDiv = document.getElementById("targetDiv"); targetDiv.style.display="block"; } function hide() { var targetDiv = document.getElementById("targetDiv"); targetDiv.style.display="none"; } </script> |
|
|
|
#8 (permalink) | |
|
Now Freelance!
Join Date: Aug 2006
Location: Warrington, UK
Posts: 476
|
Quote:
I have rarely used Javascript before when designing my sites and am not too sure how to implement it. I did have a look at MooTools but wasn't too sure how to use it. I have been looking at this: jQuery Sliding Panels and wanted to use the box where you can toggle the show/hide content. I had a go at inserting it into a test page and couldn't seem to get it to work. I could do with some help just implementing it into a blank document and looking how it functions. I didnt want to just put it into my site without knowing how it works. |
|
|
![]() |