求问select下拉列表操作,如何兼容于IE和firefox

2025-05-13 07:17:40
推荐回答(1个)
回答(1):

2.删除 option 在 firefox 是 select.remove(selectedIndex),而不是 options.remove()
输出 option[x].innerText 在 firefox 下用 options[x].textContent(firefox没有innerText,就是用textContent 来替代的)3.
动态删除select中的所有options:
document.getElementById("ddlResourceType").options.length=0;
动态删除select中的某一项option:
var sObj=document.getElementById("ddlResourceType");
sObj.removeChild(sObj.options[indx]);
动态添加select中的项option: