JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://geedmo.github.io/yamm/assets/css/yamm.css">
<link rel="stylesheet" href="http://geedmo.github.io/yamm/assets/css/bootstrap-responsive.min.css">
<link rel="stylesheet" href="http://geedmo.github.io/yamm/assets/css/bootstrap.min.css">
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<body>
<div class="container">
<div class="navbar yamm">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target="#nav1">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#"> Yamm Megamenu </a>
<div class="nav-collapse collapse" id="nav1">
<ul class="nav">
<!-- Classic list -->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown"> List <b class="caret"></b> </a>
<ul class="dropdown-menu">
<li>
<!-- Content container to add padding -->
<div class="yamm-content">
<ul class="span2 unstyled">
<li><p><strong>Section Title</strong></p></li>
<li>
List Item
</li>
<li>
List Item
</li>
<li>
List Item
</li>
<li>
List Item
</li>
<li>
List Item
</li>
<li>
...
JavaScript
/**
* Project: Bootstrap Hover Dropdown
* Author: Cameron Spear
* Contributors: Mattia Larentis
*
* Dependencies: Bootstrap's Dropdown plugin, jQuery
*
* A simple plugin to enable Bootstrap dropdowns to active on hover and provide a nice user experience.
*
* License: MIT
*
* http://cameronspear.com/blog/bootstrap-dropdown-on-hover-plugin/
*/
;(function ($, window, undefined) {
// outside the scope of the jQuery plugin to
// keep track of all dropdowns
var $allDropdowns = $();
// if instantlyCloseOthers is true, then it will instantly
// shut other nav items when a new one is hovered over
$.fn.dropdownHover = function (options) {
// don't do anything if touch is supported
// (plugin causes some issues on mobile)
if('ontouchstart' in document) return this; // don't want to affect chaining
// the element we really care about
// is the dropdown-toggle's parent
$allDropdowns = $allDropdowns.add(this.parent());
return this.each(function () {
var $this = $(this),
$parent = $this.parent(),
defaults = {
delay: 500,
instantlyCloseOthers: true
},
data = {
delay: $(this).data('delay'),
instantlyCloseOthers: $(this).data('close-others')
},
showEvent = 'show.bs.dropdown',
hideEvent = 'hide.bs.dropdown',
// shownEvent = 'shown.bs.dropdown',
// hiddenEvent = 'hidden.bs.dropdown',
settings = $.extend(true, {}, defaults, options, data),
timeout;
$parent.hover(function (event) {
// so a neighbor can't open the dropdown
if(!$parent.hasClass('open') && !$this.is(event.target)) {
// stop this event, stop executing any code
// in this...