{"id":4,"date":"2011-06-03T04:42:56","date_gmt":"2011-06-03T04:42:56","guid":{"rendered":"http:\/\/tier7.net\/blog\/?p=4"},"modified":"2011-06-03T04:46:31","modified_gmt":"2011-06-03T04:46:31","slug":"timedrop-menus-with-jquery","status":"publish","type":"post","link":"https:\/\/tier7.net\/blog\/2011\/06\/timedrop-menus-with-jquery\/","title":{"rendered":"TimeDrop Menus with jQuery"},"content":{"rendered":"<p>TimeDrop menu is a plugin for jQuery based on common drop-down methods, but allows for drop down menus that will persist until a timeout triggers them to close. This allows the user to jump off the menu for a short time, then come back to it without the menu closing.<br \/>\n<strong>jQuery.timeDrop.js<\/strong><\/p>\n<pre>\r\n\/*<br \/>\r\n  Timed drop-down menus using jQuery<br \/>\r\n  2010 Tier7.net<br \/>\r\n*\/<br \/>\r\n(function( $ ){<br \/>\r\n  $.fn.timeDrop = function() {<br \/>\r\n  \/\/---------------------------------------------------------------<br \/>\r\n  \/\/ jQuery TimeDrop Menus v0.1<br \/>\r\n  \/\/---------------------------------------------------------------<br \/>\r\n  var dropTimer = 0;<br \/>\r\n  var menu = this;<br \/>\r\n  this.hover(function(){<br \/>\r\n    $(&quot;ul&quot;, this).slideDown('fast').not('.time-drop-toggled').addClass('ti\r\nme-drop-toggled');<br \/>\r\n    menu.parents(&quot;ul&quot;).not('.time-drop-toggled').hide();<br \/>\r\n    clearTimeout(dropTimer);<br \/>\r\n  },function(){<br \/>\r\n    $(&quot;ul&quot;, menu).removeClass('time-drop-toggled');<br \/>\r\n    dropTimer=setTimeout(function(){$(&quot;ul&quot;, menu).not('.time-drop-toggled')\r\n.slideUp('fast');}, 1100);<br \/>\r\n  });<br \/>\r\n  };<br \/>\r\n})( jQuery );\r\n  <\/pre>\n<p><strong>CSS<\/strong><\/p>\n<pre>\r\n  No special CSS required at this time.<br \/>\r\n<\/pre>\n<p><strong>Code For Single Drop Down<\/strong><\/p>\n<pre>\r\n&lt;div class=&quot;time-drop-menu&quot;&gt;&lt;a href=&quot;#&quot;&gt;My Menu&lt;\/a&gt;<br \/>\r\n  &lt;ul&gt;<br \/>\r\n    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu item 1&lt;\/a&gt;&lt;\/li&gt;<br \/>\r\n    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu item 2&lt;\/a&gt;&lt;\/li&gt;<br \/>\r\n    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu item 3&lt;\/a&gt;&lt;\/li&gt;<br \/>\r\n  &lt;\/ul&gt;<br \/>\r\n&lt;\/div&gt;<br \/>\r\n&lt;script&gt;<br \/>\r\n  $(&quot;.time-drop-menu&quot;).timeDrop();<br \/>\r\n&lt;\/script&gt;<br \/>\r\n  <\/pre>\n<p><strong>Code For Multi Drop Down<\/strong><\/p>\n<pre>\r\n&lt;ul class=&quot;time-drop-menu&quot;&gt;<br \/>\r\n  &lt;li&gt;&lt;a href=&quot;#&quot;&gt;First Menu&lt;\/a&gt;<br \/>\r\n    &lt;ul&gt;<br \/>\r\n      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu item 1&lt;\/a&gt;&lt;\/li&gt;<br \/>\r\n      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu item 2&lt;\/a&gt;&lt;\/li&gt;<br \/>\r\n      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu item 3&lt;\/a&gt;&lt;\/li&gt;<br \/>\r\n    &lt;\/ul&gt;<br \/>\r\n  &lt;\/li&gt;<br \/>\r\n  &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Second Menu&lt;\/a&gt;<br \/>\r\n    &lt;ul&gt;<br \/>\r\n      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu item 1&lt;\/a&gt;&lt;\/li&gt;<br \/>\r\n      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu item 2&lt;\/a&gt;&lt;\/li&gt;<br \/>\r\n      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Menu item 3&lt;\/a&gt;&lt;\/li&gt;<br \/>\r\n    &lt;\/ul&gt;<br \/>\r\n  &lt;\/li&gt;<br \/>\r\n&lt;\/ul&gt;<br \/>\r\n&lt;script&gt;<br \/>\r\n  $(&quot;.time-drop-menu &gt; li&quot;).timeDrop();<br \/>\r\n&lt;\/script&gt;<br \/>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>TimeDrop menu is a plugin for jQuery based on common drop-down methods, but allows for drop down menus that will persist until a timeout triggers them to close. This allows the user to jump off the menu for a short &hellip; <a href=\"https:\/\/tier7.net\/blog\/2011\/06\/timedrop-menus-with-jquery\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,3],"tags":[6,7,4,8,9,5],"class_list":["post-4","post","type-post","status-publish","format-standard","hentry","category-uncategorized","category-web-development","tag-css","tag-javascript","tag-jquery","tag-web-design","tag-web-development-2","tag-xhtml"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/tier7.net\/blog\/wp-json\/wp\/v2\/posts\/4","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tier7.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tier7.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tier7.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tier7.net\/blog\/wp-json\/wp\/v2\/comments?post=4"}],"version-history":[{"count":6,"href":"https:\/\/tier7.net\/blog\/wp-json\/wp\/v2\/posts\/4\/revisions"}],"predecessor-version":[{"id":9,"href":"https:\/\/tier7.net\/blog\/wp-json\/wp\/v2\/posts\/4\/revisions\/9"}],"wp:attachment":[{"href":"https:\/\/tier7.net\/blog\/wp-json\/wp\/v2\/media?parent=4"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tier7.net\/blog\/wp-json\/wp\/v2\/categories?post=4"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tier7.net\/blog\/wp-json\/wp\/v2\/tags?post=4"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}