1 回答

TA貢獻(xiàn)2003條經(jīng)驗(yàn) 獲得超2個(gè)贊
您可以使用selectedIndex
以下屬性HTMLSelectElement
:
const firstList = document.getElementById('list1');
const secondList = document.getElementById('list2');
firstList.addEventListener('change', () => {
? secondList.selectedIndex = firstList.selectedIndex;
});
<select id="list1" name="list1" class="form-control" required>
? <option value='1'>1</option>
? <option value='2'>2</option>
? <option value='3'>3</option>
</select>
<select id="list2" name="list2" class="form-control" required>
? <option value='1'>1</option>
? <option value='2'>2</option>
? <option value='3'>3</option>
</select>
- 1 回答
- 0 關(guān)注
- 117 瀏覽
添加回答
舉報(bào)