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