更新时间:2022-05-23 22:41:31
$("#dropdown-mobile").on('change', function(){
console.log("list item selected");
var val = $(this).val();
console.log(val);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<select id="dropdown-mobile" name="select">
<option>abc</option>
<option>abcd</option>
</select>
您应该更改
$(document).on('change', 'option.class-x', function(){
console.log("list item selected");
// do whatever here
});
进入
$("#dropdown-mobile").on('change', function(){
console.log("list item selected");
// do whatever here
});