Crear elemento JavaScript con ID
var btn = document.createElement('div');
btn.setAttribute("id", "div1");
Mr. Samy
var btn = document.createElement('div');
btn.setAttribute("id", "div1");
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() *
charactersLength));
}
return result;
}
console.log(makeid(5));
Run code snippet
g = document.createElement('div');
g.setAttribute("id", "Div1");
g = document.createElement('div');
g.setAttribute("id", "Div1");
g=document.createElement('div'); g.className='tclose'; g.v=0;