"Bootstrap Button Select"
Bootstrap 3.3.0 Snippet by SeeR

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <h1>Bootstrap Button Select</h1> <div class="row"> <div class="col-xs-6 col-sm-3"> <h5>.btn-info .btn-select-light</h5> <a class="btn btn-info btn-select btn-select-light"> <input type="hidden" class="btn-select-input" id="" name="" value="" /> <span class="btn-select-value">Select an Item</span> <span class='btn-select-arrow glyphicon glyphicon-chevron-down'></span> <ul> <li>Option 1</li> <li>Option 2</li> <li>Option 3</li> <li>Option 4</li> </ul> </a> </div> <div class="col-xs-12 col-md-12"> <pre> <p>Text oder was auch immer</p> </pre> </div> </div> </div>
.btn-select { position: relative; padding: 0; min-width: 236px; width: 100%; border-radius: 0; margin-bottom: 20px; } .btn-select .btn-select-value { padding: 6px 12px; display: block; position: absolute; left: 0; right: 34px; text-align: left; text-overflow: ellipsis; overflow: hidden; border-top: none !important; border-bottom: none !important; border-left: none !important; } .btn-select .btn-select-arrow { float: right; line-height: 20px; padding: 6px 10px; top: 0; } .btn-select ul { display: none; background-color: white; color: black; clear: both; list-style: none; padding: 0; margin: 0; border-top: none !important; position: absolute; left: -1px; right: -1px; top: 33px; z-index: 999; } .btn-select ul li { padding: 3px 6px; text-align: left; } .btn-select ul li:hover { background-color: #f4f4f4; } .btn-select ul li.selected { color: white; } /* info Start */ .btn-select.btn-info:hover, .btn-select.btn-info:active, .btn-select.btn-info.active { border-color: #46b8da; } .btn-select.btn-info ul li.selected { background-color: #46b8da; color: white; } .btn-select.btn-info ul { border: #46b8da 1px solid; } .btn-select.btn-info .btn-select-value { background-color: #5bc0de; border: #46b8da 1px solid; } .btn-select.btn-info:hover, .btn-select.btn-info.active { background-color: #269abc; } /* info End */ .btn-select.btn-select-light .btn-select-value { background-color: white; color: black; }
$(document).ready(function () { $(".btn-select").each(function (e) { var value = $(this).find("ul li.selected").html(); if (value != undefined) { $(this).find(".btn-select-input").val(value); $(this).find(".btn-select-value").html(value); } }); }); $(document).on('click', '.btn-select', function (e) { e.preventDefault(); var ul = $(this).find("ul"); if ($(this).hasClass("active")) { if (ul.find("li").is(e.target)) { var target = $(e.target); target.addClass("selected").siblings().removeClass("selected"); var value = target.html(); $(this).find(".btn-select-input").val(value); $(this).find(".btn-select-value").html(value); } ul.hide(); $(this).removeClass("active"); } else { $('.btn-select').not(this).each(function () { $(this).removeClass("active").find("ul").hide(); }); ul.slideDown(200); $(this).addClass("active"); } }); $(document).on('click', function (e) { var target = $(e.target).closest(".btn-select"); if (!target.length) { $(".btn-select").removeClass("active").find("ul").hide(); } });

Related: See More


Questions / Comments: