当我添加一些> select> ex.SELECT_country,SELECT_country1,SELECT_country2我想按照从最新到最旧的顺序删除它们.但它正在从最旧的一个移到最新的一个.我以为SELECT_country是父母,我将删除他的孩子.但是父母先走了.我怎么能改变它?
var j = 0;
function add_country() {
j++;
var select = document.getElementById("SELECT_country");
var clone = select.cloneNode(true);
clone.setAttribute("id", "SELECT_country" + j);
clone.setAttribute("name", "country" + j);
document.getElementById("DIV_country").appendChild(clone);
}
function remove_country() {
var select = document.getElementById('SELECT_country');
select.parentNode.removeChild(select);
}
Run Code Online (Sandbox Code Playgroud) javascript ×1