Get selected item value from Bootstrap DropDown with specific ID
Design code using Bootstrap
<div class="dropdown-menu" id="demolist">
<a class="dropdown-item" h ref="#">Cricket</a>
<a class="dropdown-item" href="#">UFC</a>
<a class="dropdown-item" href="#">Football</a>
<a class="dropdown-item" href="#">Basketball</a>
</div>
- jquery Code
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
$('#demolist a').on('click', function () {
var txt= ($(this).text());
alert("Your Favourite Sports is "+txt);
});
});
</script>
$('#demolist li').on('click', function(){
$('#datebox').val($(this).text());
});
http://jsfiddle.net/kcpma/18/