I have the following code in my HTML file.
In the JavaScript file I am trying to detect a click on any item which has the class dropdown-item ml-2 associated with it. However, the click() function is not getting caught.
$(document).ready(function() {
$('.dropdown-item ml-2').click(function() {
alert('hello');
});
});
<span class="dropdown-item-text font-weight-bold">People</span>
<a class="dropdown-item ml-2" id="optAffiliates" href="#">Affiliates</a>
<a class="dropdown-item ml-2" id="optBusiness" href="#">Business</a>
<a class="dropdown-item ml-2" href="#">Inquiries</a>
<a class="dropdown-item ml-2" href="#">Students</a>
<a class="dropdown-item ml-2" href="#">Students</a>
</span>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="{{url('myproject/public/js/ya-jquery.js')}}" type="text/javascript"></script>