How to Write HTML or JavaScript for Drop-Down Tabs for Web Pages

How to Write HTML or JavaScript for Drop-Down Tabs for Web Pages thumbnail
A Javascript framework library enables sophisticated websites to be built more quickly.

Drop-down tabs are menus on a Web page that expand to display sub-menus when a mouse hovers over a main menu item. This functionality is usually built using a Javascript framework library that provides advanced GUI (Graphical User Interface) facilities using CSS (Cascading Stylesheets) and XML handling functions known as AJAX (Asynchronous Javascript XML). The three main Javascript framework libraries are JQuery, MooTools and Scriptaculous. The advantage of using Javascript framework libraries is they are cross-browser compatible and open source and enable developers to build sophisticated websites more quickly using standardized pre-built components. The javascript language also enables quicker rendering of Web pages because javascript is processed within a Web browser, instead of on a Web server.



There are extensions to these frameworks that provide special features to the drop-down tab. These are available from sites such as Knallgrau, LWIS, Droppy, and Superfish.



Building a basic HTML/Javascript webpage for drop-down tabs using the JQuery framework can be accomplished quickly. A basic understanding of HTML and Javascript coding is required.

Things You'll Need

  • Internet Browser
  • Text editor
Show More

Instructions

    • 1

      Open your Web browser at the JQuery download page (see Resources below). Look for the "Current Release" section, and right-click on the "Minified" link. Select "Save As...," and save the javascript file named "jquery-1.4.2.js" to your local C:\ folder.

    • 2

      Open your text editor, and copy and paste the following code into a file called C:\mydropdownmenu.html. Save the file.

      <html>

      <body>

      <style type="text/css">

      #ddt {margin:0;padding:0;list-style:none;}

      #ddt li { float:left; width:100px; background:#EFEEA0; position:relative; }

      #ddt li a { display:block; padding:10px 10px 0px 10px; height:40px;

      text-decoration:none; color:#444444; text-align:center; }

      #ddt ul{ left:0; display:none; padding:0; list-style:none;}

      #ddt ul li{ width:100px; float:left; border-top:2px solid #ffffff;}

      #ddt ul a {display:block; height:40px; padding: 8px 5px;color:#333333}

      </style>

      <script type="text/javascript" src="jquery-1.4.2.js">

      </script>

      <script type="text/javascript">

      $ltimedelay=100;

      $(document).ready(function (){

      $('#ddt li').hover(

      function () {

      $('ul', this).slideDown($ltimedelay);},

      function () {

      $('ul', this).slideUp($ltimedelay);}

      );

      });

      </script>

      <input type=hidden><ul id='ddt'>

      <li><a href='http://www.example.com'>Main Option A</a>

      <ul>

      <li><a href='http://www.example.com'>Submenu Option A1</a></li>

      </ul>

      <li><a href='http://www.example.com'>Main Option B</a>

      <ul>

      <li><a href='http://www.example.com'>Submenu Option B1</a></li>

      </ul>

      </body>

      </html>

    • 3

      Open your Web browser at C:\mydropdownmenu.html. Hover your mouse over the menu items "Main Option A" and "Main Option B" to view the drop-down sub-menus.

    • 4

      Press "Alt+Tab" to return to the text editor. Near the bottom of the file, copy and paste the following code above the line "</body>". This will create a third main menu option with two sub-menus. Then save the file.

      <li><a href='http://www.example.com'>Main Option C</a>

      <ul>

      <li><a href='http://www.example.com'>Submenu Option C1</a></li>

      <li><a href='http://www.example.com'>Submenu Option C2</a></li>

      </ul>

    • 5

      Press "Alt+Tab" to return to the Web browser. Press F5 to refresh the page. It will now display "Main Option C" with two submenus, C1 and C2.

Related Searches:

References

Resources

  • Photo Credit hypertext transfer protocol image by Pei Ling Hoo from Fotolia.com

Comments

You May Also Like

  • JavaScript Drop-down Tutorial

    JavaScript is a client-side scripting language used to create dynamic web pages. A client-side scripting language is implemented in the user's web...

  • How Do I Make a Drop-Down Box in Excel?

    Adding a drop-down box, or drop-down list, to your Microsoft Excel spreadsheet can increase productivity and decrease errors. Drop-down lists contain predetermined...

  • How to Create a Javascript Drop Down Menu With PHP

    Dropdown menus are a stylish, sophisticated technique for displaying website navigation links. A dropdown menu organizes a number of links under a...

  • An HTML Drop Down Menu Tutorial

    Web forms are used on HTML pages to collect data from visitors. Forms allow for several types of input fields including text...

  • Dropdown Menu JavaScript Tutorial

    A drop-down menu makes it possible to display large amounts of data in small amount of space. Web developers use these menus...

  • How to Create a Drop Down Menu

    When designing your website, you may want to include special features like forms for customers to fill out. Forms are used for...

  • How to Write Drum Tabs

    Tablature, better known as tabs, is a way for people who don't read music to read guitar or drum music in its...

  • How to Write Text in JavaScript

    JavaScript allows you to dynamically write text onto the page, using the document.write and document.writeln functions.

  • How to Make Drop Down Menus in a Web Page

    Drop-down menus can be a convenient way to provide multiple choices for your users without using a lot of screen real estate....

Related Ads

Featured