ragazzi ho bisogno di voi io ho questo js che crea un div con un link che serve per distruggere quest ultimo la domanda e come faccio a fare in modo che quel link sia in un altro div?non riesco a modificarlo...grazie mille
function recupero_id_ospite(id_ospite){
var newdiv = document.createElement('div');
var divIdName = 'div'+arguments[0];
newdiv.setAttribute('id',divIdName);
newdiv.style.width = "100%";
newdiv.style.height = "500px";
newdiv.style.left = "0px";
newdiv.style.top = arguments[0]+"00px";
newdiv.style.position = "static";
newdiv.style.background = "#FF0000";
newdiv.style.border = "1px solid #000000";
newdiv.innerHTML = 'this is div number '+arguments[0];
var lnk = document.createElement('a');
if(lnk.addEventListener){
lnk.addEventListener('click', (function(i){
return function(){
document.body.removeChild(i)}
})(newdiv), false);
}else
if(lnk.attachEvent){
lnk.attachEvent('onclick', (function(i){
return function(){
document.body.removeChild(i)}
})(newdiv));
}else{
lnk.onclick = (function(i){
return function(){
document.body.removeChild(i)}
})(newdiv);
};
lnk.href = '#';
lnk.appendChild(document.createTextNode("Chiudi")) ;
newdiv.appendChild(lnk);
document.body.appendChild(newdiv);}