jquery選中select的option jquery怎么設(shè)置select選中某項值?
jquery怎么設(shè)置select選中某項值?//方法1://例如,選擇aijquery的值:$(“#select”)。Val(“aijquery”)//方法2:$(“”select option[va
jquery怎么設(shè)置select選中某項值?
//方法1://例如,選擇aijquery的值:$(“#select”)。Val(“aijquery”)//方法2:$(“”select option[value=“aijquery”]”)。道具(“選定”,“selected”)聯(lián)機示例演示:jQuery的select下拉框中動態(tài)選擇option選項的兩種方法和聯(lián)機示例演示
<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控件
因為即使禁用了選擇,下拉框仍將顯示白色,這可能會讓用戶誤解,所以可以添加灰色背景色