How do I programmatically set the value of a select box element using JavaScript?

后端 未结 17 1688
轮回少年
轮回少年 2020-11-22 06:33

I have the following HTML

17条回答
  •  逝去的感伤
    2020-11-22 06:36

    I tried the above JavaScript/jQuery-based solutions, such as:

    $("#leaveCode").val("14");
    

    and

    var leaveCode = document.querySelector('#leaveCode');
    leaveCode[i].selected = true;
    

    in an AngularJS app, where there was a required

    提交评论

提交回复
热议问题