I have this function, to create a DIV on-the-fly. But now, I want to destroy this object on onclick event, but I just don't know how.
function creatediv(id) {
var newdiv = document.createElement('div');
newdiv.setAttribute('id', id);
newdiv.onclick=function(){this=null;}; //bad function
document.body.appendChild(newdiv);
}
What am I missing?
Thanks