2 回答

TA貢獻(xiàn)1757條經(jīng)驗(yàn) 獲得超7個(gè)贊
看來(lái)您之前每次都必須從 rowDiv 中刪除所有子級(jí)showPoland()并被showUkraine()調(diào)用?
嘗試這個(gè):
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貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊
嘗試這個(gè),
您可以通過(guò)以下方式清除元素內(nèi)的整個(gè) html 內(nèi)容:
document.getElementById("id of element").innnerHTML = null;
例子:
<div id="key_id">
<!-- html contents -->
</div>
<script>
document.getElementById("key_id").innnerHTML = null;
</script>
- 2 回答
- 0 關(guān)注
- 165 瀏覽
添加回答
舉報(bào)