开发者

Jquery select option using value

I have Html drop down. i want to mark "11:00 pm" as selected using jquery in single line how can i do it ?

<select name="timing" id="timing" >
      <option value="00:00 am">Midnight</option>
      <option value="11:00 pm">11 pm</option>
      <optio开发者_如何转开发n value="10:00 pm">10 pm</option>
      <option value="09:00 pm">9 pm</option>
      <option value="08:00 pm">8 pm</option>
    </select>


You can use

$('#timing').val('11:00 pm');


$('option[value="11:00 pm"]').attr('selected', 'selected');


var source = $("#option");
var v="10:00 pm";
source.val(v);
source.change();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜