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

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

I have the following HTML

17条回答
  •  暖寄归人
    2020-11-22 06:33

    I'm afraid I'm unable to test this at the moment, but in the past, I believe I had to give each option tag an ID, and then I did something like:

    document.getElementById("optionID").select();
    

    If that doesn't work, maybe it'll get you closer to a solution :P

提交回复
热议问题