You have the option to implement this using pure HTML or jQuery.
Here is an example using pure HTML:
<select>
<optgroup label="Fruit">
<option value="apple">Apple</option>
<option value="pear">Pear</option>
<option value="peach">Peach</option>
<option value="melon">Melon</option>
</optgroup>
<optgroup label="Vegetables">
<option value="asparagus">Asparagus</option>
<option value="beetroot">Beetroot</option>
<option value="broccoli">Broccoli</option>
</optgroup>
<optgroup label="Herbs">
<option value="basil">Basil</option>
<option value="dill">Dill</option>
<option value="ginger">Ginger</option>
</optgroup>
</select>
Now, here is an example using jQuery:
<div class="dropdown">
<a id="dropdown" href="#">Dropdown</a>
<div class="dropdown-menu" style="display:none;">
<h3>Fruit</h3>
<ul>
<li>Apple</li>
<li>Pear</li>
<li>Peach</li>
<li>Melon</li>
</ul>
<h3>Vegetables</h3>
<ul>
<li>Asparagus</li>
<li>Beetroot</li>
<li>Broccoli</li>
</ul>
<h3>Herbs</h3>
<ul>
<li>Basil</li>
<li>Dill</li>
<li>Ginger</li>
</ul>
</div>
</div>
And here is the jQuery code to toggle the dropdown menu:
<script>
$('#dropdown').click(function(event) {
$('.dropdown-menu').slideToggle();
});
</script>