Note that there are some explanatory texts on larger screens.

plurals
  1. POWeird behaviour of drop down menu created by jquery
    text
    copied!<p>For my personal use I develop a small dropdown menu with HTML,CSS &amp; jquery. When I run the script then menu is coming in and going off. There is some kind of minor mistake which I am not able to figure out. Here is my code. Can anyone have a look and tell me how to fix it.</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;style type="text/css"&gt; a#plinkp { background: #CCC; padding: 10px; cursor: pointer; margin-left: 600px; margin-top: 200px; position: absolute; } a#testll { background: #CCC; padding: 10px; cursor: pointer; margin-left: 600px; margin-top: 250px; position: absolute; } div#HoverSubmenu { background: #fff; position: absolute; top: -12px; left: -20px; z-index: 100; width: 165px; display: none; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45); border:5px solid; border-color:#F1F2F2; z-index:9999; } div#HoverSubmenu li a { color: #555555; display: block; font-family: arial; font-weight: bold; padding: 6px 15px; cursor: pointer; text-decoration: none; } div#HoverSubmenu li a:hover { background: #39B54A; color: #FFFFFF; text-decoration: none; } .HoverRoot { list-style: none; margin: 0px; padding: 0px; padding: 11px 0 0 0px; border-top: 1px solid #dedede; } &lt;/style&gt; &lt;script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { $('[id*=link]').click(function () { //$("#link").click(function () { $('#HoverSubmenu').insertAfter($('[id*=link]')); $('#HoverSubmenu').css({ left: $(this).offset().left + 'px', top: ($(this).offset().top + $(this).outerHeight()) + 'px', position: "absolute" }); toggleVisibility(); false; }); $("html").click( function (e) { if ($(e.target).not("[id*='link']") &amp;&amp; e.target.id != "HoverSubmenu" &amp;&amp; e.target.className != "HoverRoot" &amp;&amp; e.target.className != "HoverLI" &amp;&amp; e.target.className != "atag") { //alert(e.target.id); $('div#HoverSubmenu').fadeOut(); } }); function toggleVisibility() { var submenu = $('div#HoverSubmenu'); if (submenu.is(":visible")) { submenu.fadeOut(); } else { submenu.fadeIn(); } } }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;a id="plinkp"&gt;About&lt;/a&gt; &lt;a id="testll"&gt;My Test&lt;/a&gt; &lt;%--Hover UPS Menu start--%&gt; &lt;div id="HoverSubmenu"&gt; &lt;ul class="HoverRoot"&gt; &lt;li class="HoverLI"&gt;&lt;a class="atag" href="http://www.bba-reman.com"&gt;Ship with UPS&lt;/a&gt;&lt;/li&gt; &lt;li class="HoverLI"&gt;&lt;a class="atag" href="http://www.bba-reman.com"&gt;Ship with FedEx&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;%--Hover UPS Menu end--%&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

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