diff --git a/atividade.js b/atividade.js new file mode 100644 index 0000000..0beef35 --- /dev/null +++ b/atividade.js @@ -0,0 +1,50 @@ +function fazTabela(){ + let texto = document.getElementById("entrada").value; + let arrayValores = texto.split("\n") + let tabela = ``; + arrayValores.forEach((row, index) =>{ + tabela += `` + let rowValues = row.split(","); + if (index == 0){ + rowValues.forEach((value) =>{ + tabela += `` + }); + tabela += `` + } + else{ + rowValues.forEach((value) =>{ + tabela += `` + }); + tabela += `` + } + }) + tabela += `
${value}
${value}
` + document.body.innerHTML += tabela; + console.log(tabela) +} +// getByName(elem) +function getElementsByTagName(tag){ + let elementsWithTag = []; + recursiveSearch(document.body, tag, elementsWithTag); + return elementsWithTag; +} +function recursiveSearch(node, tag, arrayElements){ + if (node.childNodes.length != 0){ + node.childNodes.forEach((childNode) =>{ + if (childNode.tagName != undefined) recursiveSearch(childNode, tag, arrayElements); + }) + } + if (node.tagName == tag){ + arrayElements.push(node); + } +} +//Um texto vale mais que mil imagens +function replaceImageWithText(){ + let imagens = getElementsByTagName("IMG"); + for (let i = 0; i < imagens.length; i++) { + let parentNode = imagens[i].parentNode; + let span = document.createElement('span'); + span.appendChild(document.createTextNode(imagens[i].alt)); + parentNode.replaceChild(span, imagens[i]); + } +} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..d419902 --- /dev/null +++ b/index.html @@ -0,0 +1,27 @@ + + + + + + + + + E06-JS + + + + +
+ +
+ +
+ +
+ teste + + \ No newline at end of file