I'd like to have drop down menus that look like this:
Those are actually just two buttons that have a "dropdown-toggle" class and they are connected by a parent element that uses the class "btn-group".
And there are a lot of disadvantages: They don't work at all when javascript is disabled and because every entry has to be an element the page scrolls to the very top every time you select something.
So how can I style two regular drop down menus to look like these without any javascript? If possible with built in bootstrap classes.
http://www.bootply.com/0qbchZBz3B
<div class="btn-group" role="group" aria-label="...">
<div class="btn-group" role="group">
<button id="itemButton" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" value="Silver" aria-haspopup="true" aria-expanded="false">
Shirt
<span class="caret"></span>
</button>
<ul id="itemDropDown" class="dropdown-menu">
<li><a href="#" data-value="Pants">Pants</a></li>
<li><a href="#" data-value="Shirt">Shirt</a></li>
</ul>
</div>
<div class="btn-group" role="group">
<button id="sizeButton" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" value="M" aria-haspopup="true" aria-expanded="false">
M
<span class="caret"></span>
</button>
<ul id="sizeDropDown" class="dropdown-menu">
<li><a href="#" data-value="S">S</a></li>
<li><a href="#" data-value="M">M</a></li>
<li><a href="#" data-value="L">L</a></li>
</ul>
</div>
</div>
<script>
$(function() {
$(".dropdown-menu li a").click(function(){
//e.preventDefault();
$(this).closest(".btn-group").find('.btn').html($(this).text() + ' <span class="caret"></span>');
$(this).closest(".btn-group").find('.btn').val($(this).data('value'));
//$(this).css("display":"none");
console.log("DropDown value changed!")
//return; //return so that we are not actually visiting '#' (doesn't work)
});
});
</script>
I guess somewhat like this: http://jsfiddle.net/m3hpucnp/