JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/dot-luv/jquery-ui.css">
<ul>
<li class="ui-dropdown-list" >
<a href="#">Right Drop Down Menu</a>
<ul>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
</ul>
</li>
</ul>
CSS
.ui-dropdown-list ul { display: none; }
JavaScript
jQuery.fn.dropdown = function () {
var defaults = {
button: null,
menu: null,
visible: false
};
var options = $.extend(defaults, options);
return this.each(function () {
options.button = $(this);
options.menu = $(this).find("ul");
$(document).click(lift);
// when the parent is clicked, determine whether dropdown needs to occur
options.button.click(function (e) {
options.menu.is(':visible') ? lift() : drop();
e.stopPropagation();
});
// drop the menu down so that it can be seen.
function drop() {
options.button.addClass("open");
options.menu.show();
}
// lift the menu up, hiding it from view.
function lift() {
options.menu.hide();
options.button.removeClass('open');
}
});
};
$(".ui-dropdown-list").dropdown();