<article>
THIS IS THE LEARN VERSION OF THE DROP DOWN MENU.<br>
IF U WOULD SEE THE FULL VERSION, GO TO:<br><br>
<a target="_blank" href="http://jsfiddle.net/wolfwortmann/2WkPa/">http://jsfiddle.net/wolfwortmann/2WkPa/</a><br>
</article>
<hr>
<mnav>
<br>
<div class="open">click here to open the menu</div>
<div class="close">click here to close the menu</div>
<div class="dropdown">
<ul class="sub_menu">
<a href="#">
<li>
Home
</li>
</a>
<a href="#">
<li>
Web
</li>
</a>
<a href="#">
<li>
Contact
</li>
</a>
</ul>
</div>
</mnav>
<!-- NOT!!!! for the dropdown!!!! -->
<section>
<hr>
TO TRY IT SELF:<br>
ADD THIS TO YOUR HTML DOCUMENT :<br>
<br>
<!DOCTYPE html><br>
<html lang="de"><br>
<head><br>
<title>Wolf Wortmann | Home</title><br>
<meta content="text/html; charset=UTF-8" http-equiv="content-type"><br>
<style type="text/css"><br>
<!--<br>
.close{/*the close field is hidden (display:none;)*/<br>
display: none;<br>
}<br>
.dropdown{/*the dropdown menu is hidden (same how close-field)*/<br>
display: none;<br>
}<br>
--><br>
</style><br>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script><br>
<script type="text/javascript">//<![CDATA[<br>
$(window).load(function(){ <br><br>//here ist the javascript content!!<br><br>
$(".open").click(function() {//on click on the OPEN-field:<br>
$(".dropdown").css({ "display":"block" });//dropdown was showed<br>
$(".close").css({ "display":"inline" });//close-field was showed<br>
$(".open").css({ "display":"none" });//open-field was...
CSS
.close{/*the close field is hidden (display:none;)*/
display: none;
}
.dropdown{/*the dropdown menu is hidden (same how close-field)*/
display: none;
}
/* NOT FOR THE DROPDOWN: */
section{
padding-top: 100px;
}
JavaScript
$(".open").click(function() {//on click on the OPEN-field:
$(".dropdown").css({ "display":"block" });//dropdown was showed
$(".close").css({ "display":"inline" });//close-field was showed
$(".open").css({ "display":"none" });//open-field was hidden
})
$('.close').click(function() {//on click on the CLOSE-field:
$(".close").css({ "display":"none"});//close-field was hidden
$(".open").css({ "display":"inline" });//open-field was showed
$(".dropdown").css({ "display":"none" });//dropdown was hidden
});
$('.dropdown ').click(function(event){
event.stopPropagation();
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.