Good Morning, I am new to coding and learning laravel for home project. I am trying to get data from database as per dropdown selection. The code for dropdown item is as below
<div >
<button type="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i ></i>
</button>
<div id="milkstatementdropdown" name="milkstatementdropdown" aria-labelledby="milkstatementdropdown">
<li><a href="javascript:void(0);">Yesterday</a></li>
<li><a href="javascript:void(0);">Last 7 Days</a></li>
<li><a href="javascript:void(0);">Last Month</a></li>
<li><a href="javascript:void(0);">Last 3 Month</a></li>
<li><a href="javascript:void(0);">Last 6 Month</a></li>
</div>
</div>
` After selection of drop down item, need to get value and then pass the same to controller using AJAX.
below is the script for getting the selection value and process ajax.
`
$("#milkstatementdropdown").change(function(){
var duration = $(this).val();
alert(course);
// ajax call
});
`
i am not able to get the Alert..
Did i miss something and make mistake in code...
Thanks in Advance.
CodePudding user response:
try this
$('#id').on('select2:close', function () {
//do anything
});
CodePudding user response:
Try this one // You can use Anything
$('#milkstatementdropdown li a').on('click', function(){
alert($(this).text());
//do anything
});