<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!-- <script src="../js/jquery.js"></script> -->
<script src='https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js'></script>
<title>Document</title>
<script>
$(function(){
// $('select[name="mySelect"]').on('change',(e)=>{
$('#aa').on('change',(e)=>{
console.log(1111);
console.log('value', $('#aa').val());
console.log('e',e.target.value);
let this_val = $(this).children('option:selected').val();
console.log('this_val',this_val);
});
})
</script>
</head>
<body>
<select name="mySelect" id="aa">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>
</body>
</html>
我select 选择通过$(this)取不到当前的获取值,后来我看网上说要$(this).children('option:selected');
但是 不知道为什么 总是undefined ?
你用了箭头函数=> this的指向不是你想象中的$('#aa')了