i searched google to do this and mostly i found this solution:
mydiv = document.getElementById('FirstDiv');while ( mydiv.firstChild ) mydiv.removeChild( mydiv.firstChild );
instead of doing such iterations, i basically did this and it worked successfully:
document.getElementById('FirstDiv').innerHTML ="";