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 關注
- 168 瀏覽
添加回答
舉報