jq监听select值踩坑

			$("#wNoSelect").change(()=>{
				console.log($(this).get(0))//指向window
				console.log($(this).val())//报错jquery-3.2.0.min.js:4 Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
			})		
			$("#wNoSelect").change(function(){
				console.log($(this).get(0)) //获取到select元素
				console.log($(this).val(0)) //获取到下拉选中的值
			})

原因:function和()=>的this指向不同

猜你喜欢

转载自blog.csdn.net/weixin_43939111/article/details/112861316