Skip to content

Instantly share code, notes, and snippets.

@robbiegod
Created October 21, 2015 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robbiegod/bf4293db4441777c374c to your computer and use it in GitHub Desktop.
Save robbiegod/bf4293db4441777c374c to your computer and use it in GitHub Desktop.
hover function to load a submenu that is dynamically added into a standard menu.
<!-- Hidden for the contents of the submenu -->
<div id="groupsSubMenuContent" class="hidden">
<div class="subMenuGroups">
<h5>Top 5 Featured Groups</h5>
<ul>
<li><a href="#">LINK 1</a></li>
<li><a href="#">LINK 2</a></li>
<li><a href="#">LINK 3</a></li>
<li><a href="#">LINK 4</a></li>
<li><a href="#">LINK 5</a></li>
</ul>
</div>
</div>
<script type="text/javascript">
// inject submenu on hover for Groups/Topics
jQuery( "li.wt-Groups" ).hover(function() {
var groupsSubMenuContent = jQuery('#groupsSubMenuContent').html();
$( 'li.wt-Groups' ).append( groupsSubMenuContent );
},
function() {
$( 'li.wt-Groups div.subMenuGroups' ).remove();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment