Skip to content

Instantly share code, notes, and snippets.

@fandrefh
Created July 20, 2015 14:44
Show Gist options
  • Save fandrefh/57a76f97362e7cafbc07 to your computer and use it in GitHub Desktop.
Save fandrefh/57a76f97362e7cafbc07 to your computer and use it in GitHub Desktop.
function criaElemento(tag) {
var elemento = document.createElement(tag);
elemento.innerText = "Também funciona!!!";
//elemento.onclick = obterAtributosDosElementos;
elemento.addEventListener("click", obterAtributosDosElementos);
document.getElementById('sec-elementos').appendChild(elemento);
}
function obterAtributosDosElementos() {
var select = document.getElementById("slc-dados-elementos");
console.log(select);
var chaves = Object.keys(this);
console.log(chaves);
for (var i = 0; i < chaves.length; i++) {
var opcao = document.createElement("option");
opcao.value = chaves[i];
opcao.innerText = chaves[i];
select.appendChild(opcao);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment