var d = document; function del_blocks() { var main_block = d.getElementById("container"); var blocks = main_block.children; while (blocks[3]) { main_block.removeChild(blocks[3]); } }