JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<div class='btn-group'>
<a href='#' class='btn dropdown-toggle' data-toggle='dropdown'>
Tags
<b class='caret'></b>
</a>
<ul class='dropdown-menu'>
<li><label><input type='checkbox'> Example</label></li>
<li class='divider'></li>
<li><a href='#' class='add' data-prompt='Enter the name of your new tag.'>New Tag</a></li>
</ul>
</div>
CSS
body { margin: 10px; }
.dropdown-menu { paddin-top: 5px; }
.dropdown-menu label {
padding: 0 10px;
}
.dropdown-menu input {
margin-right: 5px;
float: left;
}
JavaScript
$('.dropdown-menu').on('click', 'li', function(event) {
var add, checkbox, tag;
add = $(this).find('a.add');
checkbox = $(this).find('input[type=checkbox]');
if (checkbox.length > 0) {
checkbox.prop('checked', !checkbox[0].checked);
}
if (add.length > 0) {
tag = prompt(add.attr('data-prompt'), '');
$(this).parent().prepend('<li><label><input type=\'checkbox\'>' + tag + '</label></li>');
}
event.stopPropagation();
});