<div class="btn-group">
<button type="button" class="btn btn-danger dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true" aria-
expanded="false">
Sort <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#">By Name</a></li>
<li><a href="#">By Category</a></li>
<li><a href="#">By Price</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Default Order</a></li>
</ul>
</div>
<script type="text/javascript">
$(function() {
$(".dropdown-menu li a").click(function() {
var selection = $(this).text();
alert(selection);
});
});
</script>
I would like to display in an alert box the option I selected from the list. For instance, if I select "By Category," I want the alert to show "By Category" or any related information. Please assist me with this!