如何使用 jQuery 選擇下拉選項? - How to use jQuery to select a dropdown option?

問題:

I was wondering if it's possible to get jQuery to select an <option> , say the 4th item, in a dropdown box?我想知道是否有可能讓 jQuery 在下拉框中選擇一個<option> ,比如第四個項目?

<select>
    <option></option>
    <option></option>
    <option></option>
    <option></option>
    <option></option>
</select>

I want the user to click a link, then have the <select> box change its value, as if the user has selected it by clicking on the <option> .我希望用戶單擊一個鏈接,然後讓<select>框更改其值,就好像用戶通過單擊<option>選擇了它一樣。


解決方案:

參考一: https://en.stackoom.com/question/KPVc
參考二: https://stackoom.com/question/KPVc
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章