2 回答

TA贡献1757条经验 获得超7个赞
看来您之前每次都必须从 rowDiv 中删除所有子级showPoland()并被showUkraine()调用?
尝试这个:
function selectCountry() {
var x = document.getElementById("country-list");
var result = x.options[x.selectedIndex].text;
while (rowDiv.firstChild) {
rowDiv.removeChild(rowDiv.firstChild);
}
if (result == "Ukraine") {
showUkraine();
} else if (result == "Poland") {
showPoland();
}
}

TA贡献1828条经验 获得超3个赞
尝试这个,
您可以通过以下方式清除元素内的整个 html 内容:
document.getElementById("id of element").innnerHTML = null;
例子:
<div id="key_id">
<!-- html contents -->
</div>
<script>
document.getElementById("key_id").innnerHTML = null;
</script>
- 2 回答
- 0 关注
- 124 浏览
添加回答
举报