jquery选中select的option jquery怎么设置select选中某项值?

jquery怎么设置select选中某项值?//方法1://例如,选择aijquery的值:$(“#select”)。Val(“aijquery”)//方法2:$(“”select option[va

jquery怎么设置select选中某项值?

//方法1://例如,选择aijquery的值:$(“#select”)。Val(“aijquery”)//方法2:$(“”select option[value=“aijquery”]”)。道具(“选定”,“selected”)联机示例演示:jQuery的select下拉框中动态选择option选项的两种方法和联机示例演示

<body><select id=“select”udisable“><option value=“1”>1</option><option value=“2”>1</option><optionvalue=“3”>1</option><select></body>

<script>$(“ select Disable”)。属性(“disabled”,“disabled”)。CSS(“background color”,“#eeeeee”)</script>

使用jQuery的attr方法将disabled属性添加到select控件

因为即使禁用了选择,下拉框仍将显示白色,这可能会让用户误解,所以可以添加灰色背景色