473,405 Members | 2,344 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,405 software developers and data experts.

Javascript Show/Hide Sidebar

I was browsing the Mozilla Developer Center when I came across their drop down sidebar. (live preview: http://developer.mozilla.org/en/docs..._Documentation)

I would like to use something similar if not exact to this; can anyone help me?
Oct 17 '07 #1
4 6173
acoder
16,027 Expert Mod 8TB
They're using a list (ul) for the contents and showing/hiding them by setting the style.display property to "block" and "none" respectively.
Oct 18 '07 #2
They're using a list (ul) for the contents and showing/hiding them by setting the style.display property to "block" and "none" respectively.
I don't know anything about javascript... the part I was interested in was that when you hid the sidebar, the content shifted over. The rolldown effect was cool, but I'm mainly interested in how to do the content shift. Can you be more specific?
Oct 18 '07 #3
acoder
16,027 Expert Mod 8TB
I don't know anything about javascript... the part I was interested in was that when you hid the sidebar, the content shifted over. The rolldown effect was cool, but I'm mainly interested in how to do the content shift. Can you be more specific?
When you set style.display to "block" which is the default state, the contents show. When you set it to "none", the contents are removed. So all you have to do is toggle between "block" and "none".

For example:
[HTML]<a href="#" onclick="showhide('test'); return false;">Hide</a>
<span id="test" style="display:block">Test</span>[/HTML] and the showhide function:
Expand|Select|Wrap|Line Numbers
  1. function showhide(id) {
  2.  var elem = document.getElementById(id);
  3.  if (elem.style.display=="none") elem.style.display = "block";
  4.  else elem.style.display = "none";
  5. }
Oct 18 '07 #4
When you set style.display to "block" which is the default state, the contents show. When you set it to "none", the contents are removed. So all you have to do is toggle between "block" and "none".

For example:
[HTML]<a href="#" onclick="showhide('test'); return false;">Hide</a>
<span id="test" style="display:block">Test</span>[/HTML] and the showhide function:
Expand|Select|Wrap|Line Numbers
  1. function showhide(id) {
  2.  var elem = document.getElementById(id);
  3.  if (elem.style.display=="none") elem.style.display = "block";
  4.  else elem.style.display = "none";
  5. }
Thanks a bunch, I'll try it out.
Oct 18 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
4
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
1
by: Oliver Hoehle | last post by:
Hello! This ist the source-code for an editable combobox implemented with HTML,CSS and Javascript. I have tested it with IE and Mozilla. But I don't know, if it will work in other browsers...
7
by: fernandoronci | last post by:
Hi, I've been given the task of mantaining and fixing a website which I didn't design. I'm using Internet Explorer 5.5 and 6.x. Specifically, the problem is that navigation menues (written in...
5
by: googlegroups | last post by:
I have a large table in html created dynamically. This table can grow to several hundred rows or more. I have the ability to hide or display individual rows (using row.style.display = "none") and...
1
by: Brenton | last post by:
Hi I'm new to the group so if I make a major blunder posting this here I apologise in advance. I'm not a Programmer by any stretch of the imagination and I've been trying to sort out a small...
1
by: kret | last post by:
Hi, this is my first post so first of all I would like to say hello :) Now getting to my problem. In my job I have to create an ActiveX control in .NET 1.1 that can be lunched from IE....
7
by: hollopeterb | last post by:
my javascript code works great in IE but not in Firefox, can anyone help? Thanks!! Here is the code: <script type="text/javascript"> <!-- function MM_findObj(n, d) { //v3.0 var p,i,x; if(!d)...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.