Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added 92577d4fd28985bab689439ef0285247.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added download.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions getByName.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function getByName(node, elem){
var elementos = [];
for (i = 0; i < node.childNodes.length; i++ ){
var child = node.childNodes[i];
if (child.tagName != undefined){
if(child.tagName == elem){
elementos.push(child)
}

var child1 = getByName(child, elem);
child1.forEach(element => {
elementos.push(element)
});
}
}
return elementos;
}
console.log(getByName(document.body, "SECTION"));
62 changes: 62 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html>
<head>
<title> javascript DOM</title>
<meta charset="utf-8">
<style>
h1 {
margin-left: 300px;
}
body{

color:black;
text-align: left;
font-family: Arial, Helvetica, sans-serif;
font-size:20px;
margin-top: 8%;
margin-left: 25%;
background-color: gray;
}
</style>
</head>
<body id = "pagina">
<h1>Tabela</h1>
<p>
Digite as informações que você deseja inserir na tabela, separando os itens de cada <br> linha com uma vírgula:
</p>
<textarea rows="10" cols="100"></textarea>
<table class="tabela"></table>
<button onclick="principal();">OK</button>

<script>
function altera(texto){
var vTexto=[];
var linhas = texto.split('\n');
for(i=0; i < linhas.length; i++){
vTexto[i] = linhas[i].split(',');
}
return vTexto;
}

function principal(){
var tb = document.getElementsByTagName("table")[0];
var txt = document.getElementsByTagName("textarea")[0].value;
var Tabela = altera(txt);
while(tb.childNodes.length>0){
tb.removeChild(tb.childNodes[0]);
}
for(i = 0; i < Tabela.length;i++){
var li = document.createElement("tr");
for( w = 0; w < Tabela[i].length; w++){
var colunas = document.createElement("td");
var value = document.createTextNode(Tabela[i][w]);
colunas.appendChild(value);
li.appendChild(colunas);
}
tb.appendChild(li);

}
}
</script>
</body>
</html>
76 changes: 76 additions & 0 deletions index2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Um texto vale mais que mil imagens...</title>
<style>

#botao {

background: #0066A2;

color: white;

border-style: none;



height: 50px;

width: 100px;

font: bold 15px arial, sans-serif;

margin-left: 100px;
margin-top: 200px;
border-radius: 5px;

}

</style>
</head>
<body style="background-color: blueviolet;">
<div id="geral">

<img src="92577d4fd28985bab689439ef0285247.webp" alt="" height="500" width="600" style="float: left;">


<img src="download.jpg" alt="" height="500" width="600" style="float: right;">

</div>
<button onclick="altera();" id="botao">Clique!!</button>


<script>
function altera(){
var child = document.getElementsByTagName("img");
var pai = document.getElementById("geral");

while(child.length > 0){
console.log(child.length);
pai.removeChild(child[0]);
}

var criaElemento = document.createElement("h3");
var Break = document.createElement("br");

var node = document.createTextNode("Foto do chaves no clipe El Chavo.");
criaElemento.appendChild(node);
criaElemento.appendChild(Break);
var elem = document.getElementsByTagName("div");
elem[0].appendChild(criaElemento);


Break = document.createElement("br");
criaElemento = document.createElement("h3");
node = document.createTextNode("Rochelle com olhar debochado.");
criaElemento.appendChild(node);
criaElemento.appendChild(Break);
elem = document.getElementsByTagName("div");
elem[0].appendChild(criaElemento);
}
</script>
</body>
</html>