使用 jq 获取 select 选中元素和 设置 select 选中

设置  select 选中:

//默认选中第一个
$('#serviceCode option:eq(0)').prop('selected', 'selected');

背后原理:

设置属性和值:

$(selector).prop(property,value)

获取select 选中:

var option = $('#carStyleList option:selected');

猜你喜欢

转载自blog.csdn.net/qq_37155959/article/details/81669023