Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here i have done bin using jQuery:</p> <p>1) Include latest jquery.js file in html header tag first.</p> <p>2) HTML:</p> <pre><code>&lt;ul id="nav"&gt; &lt;li&gt; &lt;a href="#"&gt; Home &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt; About &amp;gt; &lt;/a&gt; &lt;ul&gt; &lt;li&gt; &lt;a href="#"&gt; History &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt; Team &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt; Offices &lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt; Services &amp;gt; &lt;/a&gt; &lt;ul&gt; &lt;li&gt; &lt;a href="#"&gt; Web Design &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt; Internet Marketing &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt; Hosting &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt; Domain Names &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt; Broadband &lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt; Contact Us &amp;gt; &lt;/a&gt; &lt;ul&gt; &lt;li&gt; &lt;a href="#"&gt; United Kingdom &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt; France &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt; USA &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt; Australia &lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>3) CSS Styles:</p> <pre><code>ul#nav{ background-color:#445566; } ul li{ list-style:none; } ul li ul{ background-color:#558888; } ul li a{ color:#fff; text-decoration:none; } .off ul{ display:none; } .on ul{ display:block; } </code></pre> <p>4) JQuery in Script Tag:</p> <pre><code>$(function() { $("ul li ul").each(function() { $(this).parent().addClass('off'); }); $("ul li").mouseenter(function() { if ($(this).hasClass('off')) { $(this).removeClass('off'); $(this).addClass('on'); } }); $("ul li").mouseleave(function() { if ($(this).hasClass('on')) { $(this).removeClass('on'); $(this).addClass('off'); } }); }); </code></pre> <p>Try it on bin : <a href="http://codebins.com/bin/4ldqpal" rel="nofollow">http://codebins.com/bin/4ldqpal</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload