是的,这在 FF 和 Chrome 中有效,但由于某种原因在 IE 8 中无效。我正在使用单选按钮来清除表单的一部分。该部分是一个选择框,但我不想离开区域为空 - 相反,我想将其重置为页面加载时的状态。目前 IE8 只给我留下了一个空的小选择框。
html:
<select id="city_select" disabled="true" name="location_id" onchange="show_search_button();"><option selected>Select your city</option> </select>
Javascript:
document.getElementById('city_select').innerHTML = "<option selected>Select your city</option>";
我也尝试在 javascript 中使用 location_id 而不是 city_select 但无济于事.. innerText 和 innerContent 也不起作用.. 虽然 inner.HTML 在 IE8 中适用于早期功能,但这并不是试图将 innerHTML 转换为表单。有谁知道为什么这适用于 Chrome 和 FF 而不是 IE8?有没有解决办法?任何帮助表示感谢!