1.新建一个select.html
<select> <option value ="东风本田">东风本田</option> <option value ="广汽本田">广汽本田</option> <option value="一汽大众">一汽大众</option> <option value="上海大众">上海大众</option> </select>
2.js操作打开下拉框
1 function openselect(){ 2 var next=document.getElementById(1); 3 var cc = next.length; 4 next.size=cc; 5 return ''} 6 openselect();
3.选择其中一个选项
1 function selectone(){ 2 var next=document.evaluate('//*[@id="1"]/option[3]', document).iterateNext(); 3 next.parentNode.size=1; 4 next.selected=true; 5 return '';} 6 selectone();
4.执行事件
let evt = document.createEvent('HTMLEvents'); evt.initEvent('change', false, true); next.parentNode.dispatchEvent(evt);